theturtle32 / WebSocket-Node

A WebSocket Implementation for Node.JS (Draft -08 through the final RFC 6455)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with strange close connections

filmen opened this issue · comments

Hello,
I've a strange problem to keep a client connected for a long time.
Here is the scenario: my node app sends events to real-time dashboard where users are connected by browser via websocket and, sometimes the websocket connection doesn't remain up and the user doesn't receive the new events, expecially when a user is connected from home (ex. works in smartworking).
I've tried a lot of things:

  • set false keepalive of module and write a custom new keepalive (with setInterval and setTimeout to handle the websocket connection of every user) that drop connection after 10 seconds if the user's browser doesn't answer at keepalive message;
  • remove my custom keepalive (because doesn't fix the issue), use the keepalive of module and tune the settings to try to keep clients connected with this values:
    keepalive: true, keepaliveInterval: 20000, keepaliveGracePeriod: 10000, dropConnectionOnKeepaliveTimeout: false, disableNagleAlgorithm: true, fragmentOutgoingMessages: false
  • implemeted a round trip to check latency between my server and the user's browser (for clients that worked in smartworking sometimes are very high, on average 5/6 sec. and sometimes longer than 10 seconds - values ​​are too high in my opinion);
  • the error handler didn't show issue; only with the last modifications (use keepalive module), I see this "Error: read ETIMEDOUT";
  • firewall doens't have rules that blocks traffic on port with the app works;
  • It is possibile that a user VPN increase the latency and so the module drop the connections?

I have tested the code it with lan, wi-fi and 4G tethering and I don't have any problem but my clients, with theirs connections, have this problem also after the use the keepalive module.

What can I do to fix this situation?
I'm working in a new version of app with node 14.15.2 and last version of module (1.0.33) but meanwhile I have to fix this issue.
Thanks in advice.

Node version: 6.14.4
Module version: 1.0.23
SO: Debian 10

I have same issue

Temporary fixed for my case by adding ping method, and if it fails - I using force reconnect

Temporary fixed for my case by adding ping method, and if it fails - I using force reconnect

Hi! Do you use ping/pong function of connection instance (WebSocketConnection) or you have implemented a custom ping/pong?

@filmen @Sasha2018RL I stumble upon the same issue, did you solve this?
For now, I keep restarting my app every week

@filmen @Sasha2018RL I stumble upon the same issue, did you solve this?
For now, I keep restarting my app every week

I moved to socket io

@Sasha2018RL Can you share your old ping method for temporary fix please?