I am setting up both a socket.io server and Companion’s uppy.socket() on the same http server instance.
Companion doesn’t use socket.io so i can’t use socket.io-client to connect to it. If both servers are set up on the same http.Server instance, they may both receive incoming WebSocket connections. In that case i should add something to Companion that ignores connections that are not intended for Companion.
and how do i add something to Companion that ignores connections that are not intended for Companion ?
server.js
const companion = require("@uppy/companion")
const express = require("express")
const { createServer } = require("http")
const { Server } = require("socket.io")
const app = express()
const httpServer = createServer(app)
const io = new Server(httpServer, {
serveClient: false
})
app.use("/companion", companion.app(options))
httpServer.listen(3000)
companion.socket(httpServer)
this giving me error:
companion: 2022-12-01T21:47:09.881Z [info] socket.connect connection received
from /socket.io/?EIO=4&transport=websocket&sid=LdGVCwuehiB4bzJAAAAA
node:events:368
throw er; // Unhandled ‘error’ event
^
Error: Invalid WebSocket frame: invalid UTF-8 sequence