Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ping time out #33

Open
contact-circularblue opened this issue Dec 29, 2016 · 11 comments
Open

ping time out #33

contact-circularblue opened this issue Dec 29, 2016 · 11 comments

Comments

@contact-circularblue
Copy link

Hi,
I am using socket.io and with Node.js on server. The client ESP8266 connects successfully but the problem that i am facing is 'ping time out'. When the connection is idle for around 1-2 minutes the the ESP8266 client ping time outs on the server and gets disconnected.

@washo4evr
Copy link
Owner

Hi,
yes this is a know "issue"
I put "" since it is not actually a big issue

im still hoping to have more free time since I moved recently closer to work so I can resume my work
you can use a timer library to 'ping' every 10s or so to be sure not to loose connection

let me know if your need help
(it will be in the next version by default

@vlp-github
Copy link

Hello @washo4evr ,

Any hint where we can search into your code to help you fixing this issue ?

++

@washo4evr
Copy link
Owner

Hi,

Yes, I would recommend to look at void SocketIOClient::heartbeat(int select)
if you can call that function every 10s, 30s...or anything like that, then you wont get disconnected

I use the timer library to do that and it work
already kept my ESP8266 updatiing my server all night long

I ordered an ESP32 last week, I should be getting it soon.
Then it will be time to (finally) update this library.

Thanks for your patience

@vlp-github
Copy link

Yes I have noticed that if you keep on sending data, the connexion never break.
Calling herthbeat each 10s could be a "solution", but is doesn't really fix the issue.
Do you know if the connection is broken by the server or by the ESP ?

@vlp-github
Copy link

vlp-github commented Jul 18, 2017

I have added an heartbeat each second => the ESP is connected and operational since 8 days (non stop !) .

@washo4evr
Copy link
Owner

This is great news.

from my testing, you can lower the heartbeat to every 30 s and it should be fine (will also save some power if running on battery)

@vlp-github
Copy link

Yep, but do you have any hint of the root problem ? Or an heartbeat is required into the core structure of socket.io ?

off topic: french btw ? I saw french words into your code !

@vlp-github
Copy link

@washo4evr just to let you know that considering that I have talking to my server each 3' to check if it is still online I don't need heartbeat at all. The server ping is just like the heartbeat function but with a server state as a return. My ESP uptime is now: 2 months without any reboot !

@washo4evr
Copy link
Owner

Hi,
Et bonjour aussi.

This is great news.
2 months without crash is great.

I finally got my ESP32 working on my machine.
I hope to have good news soon (Socket.IO v2.x + ESP32)

@washo4evr
Copy link
Owner

Socket.IO v2.x + ESP32 are now supported

@mulderox
Copy link

mulderox commented Dec 15, 2017

Dear all,

I don't know if this subject remains hot, however I would like to share how am I handling the pingTimeout.
First of all, on the server side I am using nodejs/socket.io where we can use the following options to set the socket.io: pingInterval: 10000, pingTimeout: 5000. Upon new readHandshake pingTimeout can be read as follows:
int pingtimeoutindex = tmp.indexOf("pingTimeout") + 7; int pingtimeoutendindex = tmp.indexOf("}", pingtimeoutindex + 6); int pingtimeoutcount = pingtimeoutendindex - pingtimeoutindex - 6; for (int i = 0; i < pingtimeoutcount; i++) { pingTimeoutRead[i] = databuffer[i + pingtimeoutindex + 6]; } //convert pingTimeout to int pingTimeout = atoi(pingTimeoutRead);
This enables me to use the same pingTimeout on my ESP8266 to keep the connection alive with the same interval defined on the server side - no more, no less.
On ESP8266 loop I can now use this external pingTimeout value and apply the heartbeat(0) like washo4evr does in the example.

Hope this helps someone with the keep-alive issue.

Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants