[Bug?]WiFiClient.connected doesnt notice connection loss.

fredlllll
Posts: 2
Joined: Sun Jul 09, 2017 6:32 pm

[Bug?]WiFiClient.connected doesnt notice connection loss.

Postby fredlllll » Sun Jul 09, 2017 6:39 pm

as the headline states. WiFiClient.connected doesnt change when the client ESP loses power, or otherwise loses connection.

here is my code https://pastebin.com/0dk6EXyE

connect to port 10000 and send LED(ON); or LED(OFF); to switch pin 2 on and off.

as you see im looping using while(client.connected()). when i now power off the client esp, that is sending messages in a loop (basically a remote blink), the server will always get a true returned. the connected method uses errno to check if anything went wrong, but errno stays at 11, before and after powering off the client esp. that leads to the server endlessly looping and waiting for data from a dead connection.

can maybe someone from the team say something about this?


fredlllll
Posts: 2
Joined: Sun Jul 09, 2017 6:32 pm

Re: [Bug?]WiFiClient.connected doesnt notice connection loss.

Postby fredlllll » Mon Jul 10, 2017 7:55 pm

thanks wasnt aware of that. i have modified my ap code to send a dummy message every second. it now works as expected. can i send an empty message though?

i now get horrible delays sometimes when receiving messages on the server. when i dont send a dummy message every second it works just fine.

here the server code https://pastebin.com/XMpVfA2q and here the client code https://pastebin.com/bMX3wPvJ (you can just remove the display stuff)

can anyone confirm that there is erratic behaviour sometimes when client.write(";", 1); line is enabled? with the line commented everything works fine, but the server doesnt recognize a dropped connection. with it uncommented, i notice little hickups when receiving messages. its gets worse when not reading the stream on the client side with

while (client.available()) {
client.read();
}

Who is online

Users browsing this forum: No registered users and 66 guests