washo4evr / Socket.io-v1.x-Library

Socket.io Library for Arduino
108 stars 58 forks source link

Client (Adafruit Feather Huzzah) disconnects after one minute #56

Closed alessandrocapra closed 6 years ago

alessandrocapra commented 6 years ago

Hello, as in the title the connection works just fine, but after approximately a minute the connection with socketIO on the nodeJS server is lost, with the client apparently sending the disconnect message to the server.

How could I debug this? The client.monitor() does not show any disconnect message.

Thanks!

Ruttmann commented 6 years ago

I guess that there's a timeout is set when the device connects to the server. I took a look at the library code but didn't find anything related.

Are you disconnected after 1 minute of inactivity? If this is the case, the probable cause is the timeout.

A possible workaround should be a routine that exchanges "keep alive" messages with the server every 30 seconds, for example...

washo4evr commented 6 years ago

hi,

Yes, the server will kill the connection without a keepalive. I havent had much time but I'm planning on adding that to the next release

alessandrocapra commented 6 years ago

A possible workaround should be a routine that exchanges "keep alive" messages with the server every 30 seconds, for example...

Yep, actually that's what it was! I checked the code and I tried to call the monitor() function every 30 seconds, because I saw that there is an handshake in place there and it seems to be working! So basically I just have it running every 30secs and sending an emit event to the server, that's it.

Btw @washo4evr I cannot thank you enough for your efforts in this library, I'm using it for my Master's thesis and it's been super helpful! If I can help somehow to improve it you definitely deserve that help :)