-
Notifications
You must be signed in to change notification settings - Fork 555
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
Issues detecting when connection is lost to server #203
Comments
what you are looking for is the ping/pong messages of the ws protocol, will help you. Note: |
@Swedish-Coder, have you find a workaround? I am facing the same problem. I cannot use the ping message as we are using the websocket as a tunnel to mqtt. The websocket client writes on the secure tcp, but it seems that it does not update the connection status. |
@odelot We implemented an async ping method and have a pong timer. there we are are not pinging our destination but rather a google dns server (8.8.8.8). If the pong timer exceeds previous ping + timeout we close the connection. It's not an elegant solution but it gets the job done. |
@Swedish-Coder Thank you I am investigating this and it seems that WifiClientSecure.write returns with success even though the device has no internet connection. The websocket code is ok. As we are using TCP, it does not seems right. The write function should just return success if it receives the ACK packets from the remote server, isn't it right? The write function is a blocking function, right?. And the websocket library use the WifiClientSecure.setNoDelay(true) to turn off Nagle algorithm to combine small tcp packages in one. I don't know if it is a bug or a caracterist from the simplified secure tcp implementation done by the comunity. I opened an issue fo the Arduino ESP team esp8266/Arduino#3517 I would love to know if it is a bug or the way it is on ESP before implement some workaround, as this one that you suggested (thank you very much btw). |
I had a similar problem, I'm broadcasting some data and if a client drops off WiFi before closing the connection, it hangs on the broadcast call repeatedly for 2s at a time. It seems that the timeout does not cause it to disconnect. It takes a long time for it to realize the dropped client. As a workaround, I force a disconnect if the broadcast takes near 2s. Would it make sense for the library to kill any connection that times out? |
Having the same issue + ping freezes ESP for 600s after 2-3 pings until (assumption) TCP timeouts. code:
Output (WAN cable was disconnected after the first WS Ping):
After this it got stuck for some 630 seconds
|
Having trouble finding out whether or not connection to a server is present or not. (using SSL)
When the connection is lost on the server side there is no event being triggered on the client.
If simple the connection is terminated on our end (pulling WAN) the client state from ClientContext keeps reporting state 4 (ESTABLISHED).
We have a check implemented which determines if we have connection to the server. This check works well before connection has been established to the server.
We are sending using sendTXT, which returns true even if there was no WAN connected.
We are using the ESP8266 core for Arduino 2.4.0 rc1 alongside the arduinoWebSockets.
Is there a check that we missed that we can use before we try to send data to our webserver?
The text was updated successfully, but these errors were encountered: