socket.io connections failing after integrating peer server in my code
Hretic opened this issue · 3 comments
hi as you know public server is down so i tried to host my on peer server
i already had a nodejs/express server up for chat ... so i tried to integrate peer server on my chat server
here is simplified version of my code
const env = require('dotenv').config({ path: '.env' })
const express = require('express');
const { ExpressPeerServer } = require('peer');
const fs = require('fs');
const app = express();
const https = require('https');
const http = require('http');
let server ;
if(env.parsed.PROTOCOL === 'https')
{
// server = create https server
}
else
{
server = http.createServer( app);
}
const { Server } = require("socket.io");
const io = new Server(server);
const peerServer = ExpressPeerServer(server, {
debug: true
});
app.use('/peerjs', peerServer);
io.sockets.on('connection', function(socket) {
console.log(`@ connection | socket -> ${socket.id} |`);
});
var PORT = env.parsed.PORT || 8080
server.listen(PORT, () => {
console.log(`listining to port ${PORT} `);
});
the problem is after adding peer server to my code i cant establish any socket.io connection to the server ... i get no errors in the server i just get the client side error
WebSocket connection to 'ws://localhost:8080/socket.io/?EIO=4&transport=websocket' failed: Invalid frame header
server is up and working , if i type localhost:8080 in the browser i will get the response
if i remove peer server code it would work fine
i can move peer server to separate code and run on a different port but i prefer to keep it in this code
any idea why this happening ?
Transferred. This is probably the better place for it.
Can you also post the client code? Unfortunately I have no experience with socket.io so far.
I don't think it's a bug in the PeerJS server code. I would still look into it, but I can't promise anything.
The official server is back online, maybe it's no longer relevant for you. peers/peerjs#939 (comment)
same problem when hosting with replit
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.