I have an unpleasant issue where Chrome users have to wait a few seconds for their user gestures to become effective. I found that the WSS connection has to be restored depending on previous traffic. Based on a similar question, I experimented with Chrome and Firefox for two hours.
Environment: Windows 10, Server Node "socket.io": "^2.3.0", Client "socket.io-client": "^2.4.0"
I ran a simple test with both Chrome and FF and found the following:
- I have been very careful not to have any exceptions in my program flow.
- My clients connect to my server with a single wss connection.
- I was able to reproduce the problem on localhost (and it looks similar in production). With Chrome, a keep alive tick from client to server results in a reconnect after 5 minutes. In other words, the keep alive message after every 990ms made the problem worse in Chrome and had no measurable effect in FF.
- In Chrome, a number of messages close to 100 resulted in a reconnect of the client every minute after a pause of 5 minutes.
- In Chrome, a second session in another tab results in an immediate reconnect every minute. In Firefox, there is a similar behavior that depends on the focus of the tab. If I switch tabs in FF, the client gracefully reconnects before the user needs to wait for a reconnect.
Based on my observations, I've come to the conclusion that Chrome users are in disadvantage. In this case they have to wait a second or two before my app responds. This is not the case with FF due to a different connection management.
What can I do? Do I need a newer version of "socket.io"? Are there any other tricks?