platformio-projects icon indicating copy to clipboard operation
platformio-projects copied to clipboard

question. websocket handle connection lost

Open tedLiu0518 opened this issue 3 years ago • 1 comments
trafficstars

Hello, I tried to make your code work for another project and I found that the WebSocket event handler seems can't handle connection lost. I wonder what happens if my connection is suddenly lost while I am holding the button. It seems that because the server can't receive the stop message then the drone will continue running. I did some research and find that the ping pong method maybe useful. But I also noticed that there are only a few blogs & projects which use or mention this method. So I wondering whether I am totally wrong or maybe there is more elegant way to achieve that or websocket & esp32 is just not suitable for these kinds of work.

tedLiu0518 avatar Aug 18 '22 12:08 tedLiu0518

That's interesting. I run across one issue in one of my other project wherein I am sending a binary content in my websockets message instead of the normal messages. I am seeing the connections gets closed for some reason. I did a debugging in both the client and the server and found out the issue by logging them.

Just like you, I read that this is where the ping and pong method should help you in determining if the connection is still alive. I explored this one and tried it but currently I forgot if I have posted this code. Sorry.

IMHO, I think ESP32 is a pretty stable device and if ever a websocket connection gets dropped, I would put a code in my program that would retry the connection nevertheless. If this is a drone, I would stop it from what it is doing until the reconnection is successful. Although, I have not been in this situation so I cannot comment deeply as of this moment.

donskytech avatar Aug 19 '22 05:08 donskytech