question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

socket.io failing over time for Chrome and Firefox

See original GitHub issue

You want to:

  • report a bug
  • request a feature

Current behaviour

We cannot reproduce this reliably, but this is a description of our server setup and issue.

We are running socket.io 2.2.0 on a Node.JS/Express server.

After about 12 hours our server does not respond to emissions from clients on desktop Chrome and Firefox. It continues to function on Edge, Safari, and mobile Chrome/Safari.

For example:

Server:

io.on('connection', (socket) => {
    socket.on(‘test’, (data) => {
       console.log(“This is a test”)
    })
})

Client:

this.socket.emit(‘test’)

In this example, we see the expected behavior during the first 12 or so hours of the server’s uptime. “This is a test” is fired as soon as the client emits.

After that, perhaps due to gradual load on the server (though we typically never have more than 20 clients connected at once), the server stops listening to the client. Despite verifying that the client has emitted ‘test’, the server never logs “This is a test”. Again, this only occurs on desktop Chrome and desktop Firefox.

This seems odd because if the server was overloaded - it should recover when the number of clients goes down. In addition, why would excess load suddenly permanently disable the ability for Chrome and Firefox to send emissions to our server? We know that the websocket connection is being established from the client by looking at the network logs. We also see that the connection is sending pings but never receiving pongs from the server.

Expected behaviour

Chrome and Firefox sockets continue to operate as normal.

Setup

  • OS: Ubuntu 18.04
  • browser: Desktop Chrome, Desktop Firefox
  • socket.io version: 2.2.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Novivycommented, Jul 9, 2020

Since i updated socket io package, i don’t have this issue anymore (server running since 3 weeks now without issues)

0reactions
chevettcommented, Jul 9, 2020

We were working around this issue by restarting the our app fairly often, but we stopped that a while ago and everything is running as expected again. Thank you very much 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Socket.IO not working in Chrome and Firefox on Windows
I have made a Facebook like chat server and client using node.js (0.10.10), socket.
Read more >
Troubleshooting connection issues | Socket.IO
When a browser tab is not in focus, some browsers (like Chrome) throttle JavaScript timers, which could lead to a disconnection by ping...
Read more >
The WebSocket API (WebSockets) - Web APIs - MDN Web Docs
desktop desktop Chrome Edge WebSocket Full support. Chrome4. Toggle history Full support. Edge12. Toggl... WebSocket() constructor Full support. Chrome4. Toggle history Full support. Edge12. Toggl...
Read more >
Client WebSocket disconnects when browser is minimized or ...
To avoid the issue, either disable the feature "Intensive throttling of Javascript timer wake ups" in Chrome or change the inactivity-timeout to ...
Read more >
websocket is closed before the connection is established ...
Socket IO with React and Express Error: "WebSocket connection to '. ... Tested on Firefox version 79.0, 81.0, and 83.0a1; For Chrome, most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found