Closed johnm545 closed 3 years ago
Thanks for MCVE.
Looks like the seperate flags have to come back.
You may be right. I'm really curious about how this can happen, but it is okay to restore two bools instead of one.
It is curious, i didn't suspect the _write_some_from_cb at first. Can you try adding a debug print to your _write_some_from_cb, if that is firing off every 500ms like mine does then it's clear from the code that the connection will timeout prematurely. I haven't messed around with lwIP but there's always the off chance that my build is somehow borked.
Edit: _write_some_from_cb gets called from _poll, which explains why it runs regularly. This means that the for loop in _write_from_source will also get broken when _write_some_from_cb clears the _delaying flag, but there it doesn't matter because there is a do...while(true) loop around the whole thing.
That is an interesting test to do. #6483 will restore previous code. Pushing this issue to v3.0.0 so we don't forget about it.
I've tested #6483 and can confirm it fixes the issue, thanks. Feel free to close.
Not closing this issue so one/I can try to understand why a single bool causes issues.
Closing. Better is the enemy of free time. Bug was already cleared.
Basic Infos
Platform
Settings in IDE
Problem Description
This one has been introduced by #6454 and had me scratching my head for a couple of hours
Connections are timing out after about 250 ms rather than the default 5000 ms. You won't notice it on nearby servers that response fast. For some reason test.mosquitto.org is slow for me, and this bug pops up. To reproduce you might need to hunt around for a server with slow ping. But it's clear what is happening from the logs below.
It happens because the ClientContext _write_some_from_cb() method seems to be called on a timer every 500ms (even when there's nothing to send). It then clears the delaying flag which causes the loop in ClientContext connect to timeout prematurely. Before #6454 we had seperate flags for _connect_pending and _send_waiting, and _write_some_from_cb() would only clear the _send_waiting flag.
Looks like the seperate flags have to come back.
I have added some extra debug prints to track it down, as per the snippets below
loop in connect method, line 134-138
MCVE Sketch
Debug Messages