Search code examples
javascriptnode.jssocket.ioxmlhttprequest

Stalled connection with socket.io in xhr-polling mode


I have a problem with socket.io application for nodejs. I have several browser windows in my application, all of them are connected to nodejs. Application is not a heavy loaded one yet. Sometimes something hapens to socket.io, so that .emit() command on browser is not executed (i.e. server doesn't see it). nodejs console/logs shows no crashes/exceptions. Application stays in this blocked state for ~30 seconds and then resumes correct work. Browser console log shows 400 error for one of socketio request.

Any ideas why this happens and how to cure/diagnose it?


Solution

  • I have found a root cause for this problem. Chrome has a limit of 6 open HTTP requrests. So you can't have more then 6 tabs doing socketio XHR poll exchange with the server. 7th tab would behave as if server is not available.

    Reduce number of connections, or may be use websocket mode, it works fine.