Closed m2kar closed 1 year ago
Don't know if this helps but I pass the express server straight to the WebsocketServer. This works fine.
//
// Create an HTTP server.
//
const server = http.createServer(app);
//
// Create a WebSocket server and pass the express webserver.
//
const wss = new WebSocketServer({ server });
wss.on('connection', (socket, request) => {
console.log('ws client connected, ' + socket._id + ', ' + request.url);
});
@m2kar A PR with documentation updates with your findings would be much appreciated!
How to run ws on the same port as a http Express?
I tried the example
express-session-parse
given byws
(link), and replace theconst { WebSocketServer } = require('ws');
toconst WebSocketServer = require('rpc-websockets').Server;
, and add ahello
remote function, but it didn't work. The client has no output, the server output is onlyParsing session from request..
.What need I do?
The source code of server and client are :
server
client