-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uWS support is a bit broken on Windows #3100
Comments
I seem to be having the same issue on windows 7 latest chrome. Updating my krama timeout made it run, but extremely slow.
|
I'm getting this too! It's been driving me crazy. Windows 10. Happens in either chrome or firefox. Does not occur on my macbook. Basically, with 2 clients connected, some emits are basically ignored until some other code gets triggered on the server, or if nothing happens, the server's reply can be delayed for several seconds. I have replicated this on a clean project, using express + io. An example of console logging a counter emitted from client and then sent back from the server. You would normally expect to see something like this:
But when 2 clients are connected, you get this random offset:
I've noticed that setting a random interval function on the server can trigger the server to reply faster. E.g. if you add this code randomly anywhere on the server, it will trigger the event on every tick.
With this code you would see something like this (when2 clients are connected).
|
Same applies to socket,io. |
I get the exact same behavior. Would be nice to have a fix with uws. |
Related: - socketio/socket.io#2956 - socketio/socket.io#3100 Fixes #536 Fixes #516 Fixes #474
I confirm this issue. I see the same behavior in Win 10 -- but it works correctly in the Linux subsystem of Win 10. (Same codebase, just reinstalled node_modules.) I see similar behavior when I connect from a browser or from another Node.js application. The fix from @Hughp135 works for me too: if (/^win/.test(process.platform)) {
console.warn('Starting uws bug-hack interval under Windows');
setInterval(() => {}, 50);
} |
Same happens to me on Windows 7 machine, where is working well on Debian (with same code). |
uWS causes major delays - socketio/socket.io#3100
Thank you so much,this issue confued me serval days,finally got your tips!!thank you ! |
For future readers: Documentation: https://socket.io/docs/v3/server-installation/#Other-WebSocket-server-implementations |
You want to:
Current behaviour
Only in Windows when using uWs:
Huge delay between websocket data is parsed, and event is emitted to server event listeners, when more than one client is connected.
Steps to reproduce
Expected behaviour
Event emitter should fire within 1-2ms.
Setup
Other information (e.g. stacktraces, related issues, suggestions how to fix)
socket.io:server initializing namespace / +0ms
socket.io-parser encoding packet {"type":0,"nsp":"/"} +3ms
socket.io-parser encoded {"type":0,"nsp":"/"} as 0 +0ms
socket.io:server creating engine.io instance with opts {"path":"/socket.io","initialPacket":["0"]} +1ms
socket.io:server attaching client serving req handler +5ms
socket.io:server incoming connection with id uLSPqVnrkgVklbmJAAAA +1s
socket.io:client connecting to namespace / +2ms
socket.io:namespace adding socket to nsp / +0ms
socket.io:socket socket connected - writing packet +4ms
socket.io:socket joining room uLSPqVnrkgVklbmJAAAA +1ms
socket.io:socket packet already sent in initial handshake +1ms
user connected <-- FIRST CLIENT CONNECTED
socket.io:socket joined room uLSPqVnrkgVklbmJAAAA +3ms
socket.io-parser decoded 2["test",{}] as {"type":2,"nsp":"/","data":["test",{}]} +4s
socket.io:socket got packet {"type":2,"nsp":"/","data":["test",{}]} +1ms
socket.io:socket emitting event ["test",{}] +0ms
socket.io:socket dispatching an event ["test",{}] +0ms
test {}
socket.io:server incoming connection with id QfIEBNCsI5InQCrgAAAB +15s
socket.io:client connecting to namespace / +0ms
socket.io:namespace adding socket to nsp / +0ms
socket.io:socket socket connected - writing packet +1ms
socket.io:socket joining room QfIEBNCsI5InQCrgAAAB +0ms
socket.io:socket packet already sent in initial handshake +0ms
user connected <--- ANOTHER CLIENT CONNECTED
socket.io:socket joined room QfIEBNCsI5InQCrgAAAB +1ms
socket.io-parser decoded 2["test",{}] as {"type":2,"nsp":"/","data":["test",{}]} +5s
socket.io:socket got packet {"type":2,"nsp":"/","data":["test",{}]} +20s <--- THIS IS THE PROBLEM, 20sec delay!
socket.io:socket emitting event ["test",{}] +1ms
socket.io:socket dispatching an event ["test",{}] +0ms
test {}
socket.io:client client close with reason transport close +7s
socket.io:socket closing socket - reason transport close +1ms <--- DISCONNECTED ONE CLIENT
socket.io-parser decoded 2["test",{}] as {"type":2,"nsp":"/","data":["test",{}]} +5s
socket.io:socket got packet {"type":2,"nsp":"/","data":["test",{}]} +1ms
socket.io:socket emitting event ["test",{}] +0ms
socket.io:socket dispatching an event ["test",{}] +0ms
test {}
A workaround is to change the wsEngine to ws in the options:
const io = require('socket.io')(httpServer, { wsEngine: 'ws' });
The text was updated successfully, but these errors were encountered: