autobahn-js icon indicating copy to clipboard operation
autobahn-js copied to clipboard

Add websocket ping-pong heart-beating when run on NodeJS

Open photonbit opened this issue 8 years ago • 3 comments

Although in autobahn there is a reconnect mechanism that works for most cases, I've found at least one where I need a reconnect in a lower level.

I am using latest versions of AutobahnJS for node and crossbar.io.

If the computer where the node/Autobahn application is running is suspended for a long time or it is awaken in another network, Autobahn detects the disconnection and tries to connect, but the underlying connection seems to be fixed to the old HTTP connection and it will never connect again.

For that case the only thing that works for me is recreating the transport with the websocket transport factory and then connecting again.

I can prepare a patch this myself in a similar fashion as is done in the rawsockets transport, if this solution seems right.

Thanks!

photonbit avatar Mar 08 '16 11:03 photonbit

The problem is: the WebSocket API in browsers does not expose WS level ping/pongs

oberstet avatar Mar 18 '16 16:03 oberstet

I need to do more thorough tests on the browser, but I think this is not a problem because the communication is reset after recovering the network. For node I made a quick & dirty modification that is working: I setup a ontimeout on the transport connection definition that is called only in the node websocket implementation. If an similar approach makes sense, I could dig a little deeper and propose something less quick & dirtyish.

photonbit avatar Mar 18 '16 23:03 photonbit

for example, we could add then:

  • "auto_ping_interval": 10000,
  • "auto_ping_timeout": 5000,
  • "auto_ping_size": 4,

oberstet avatar Oct 16 '19 10:10 oberstet