sitegui / nodejs-websocket

A node.js module for websocket server and client
MIT License
736 stars 155 forks source link

Keep Alive? #44

Closed dannysmc95 closed 4 years ago

dannysmc95 commented 7 years ago

Hi there,

I am currently using this for a work project, I am struggling to see why I keep getting this issue: 'This socket has been ended by the other party', I assume it needs some kind of keep alive? or is this already included with this?

Thanks, Danny

BadOPCode commented 7 years ago

How long are you connected before it drops the socket? A lot of routers (most) will drop idle sockets after a couple of minutes. You can either send a keep alive or if you want to keep it slimmer you can check for the close event and just reconnect if it's not closing for a good reason. :)

dannysmc95 commented 6 years ago

Thanks @BadOPCode that's not a bad shout! When you say keep alive, I thought this library had a keep alive? Apparently you can set it in the websocket server connection scope.

sitegui commented 6 years ago

Hi @dannysmc95 , you're right, this lib does not change the default Node's keepAlive.

However you can use socket API to change that: myWebSocketConnection.socket.setKeepAlive(true)