-
Notifications
You must be signed in to change notification settings - Fork 7.6k
WiFiClient::flush() can get stuck indefinitely #4736
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
Comments
Having the same issue. The while loop inside
|
Ahh I think I found the culprit. The call to I fixed the code by changing the implementation of void WiFiClient::flush() {
if(available()){
while(read() >= 0) {};
}
} This way the |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
I dare you to close the issue 🤣 |
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future. |
I had the same issue, that would hand PubSubClient::connected() if the connection was lost and it lead to the same spot in WiFiClient::flush(), where available() reported non-zero byte but recv always returned 0. Checking errno anyways shows this: |
Now I get
I suppose it's better for not hanging anymore though the error seems little out of place. Adding bit more logging I see before
|
Thanks for answer, we will test this. |
I also see this when there are remaining bytes to be read for an HTTPClient request but the client has since disconnected "gracefully". recv returns 0 and flush() gets stuck in a loop since the original value returned by available() (used to set the local variable 'a') is non-zero.
Previous versions of HTTPClient.cpp, its disconnect() function didn't call flush, but instead sat in a while loop reading one byte at a time until _client->available() was no longer > 0. But the latest HTTPClient's disconnect() function was updated to call WiFiClient::flush() because the previous version of disconnect was "taking too long" when the number of bytes remaining was large. See also #6277 A similar change was also made to HTTPClient.cpp's end() function e3a5ae4 What's concerning is that according to the man page for recv, it should be returning -1 not 0 when there is an error. And I clearly see errno being set to 128 when currently recv is returning 0. https://pubs.opengroup.org/onlinepubs/7908799/xns/recv.html
Unless errno 128 (socket is not connected) is considered an orderly shutdown.. |
When res == 0, you can check to see if errno is set. In my testing errno is always 128 when this happens ("Socket is not connected". |
The problem persists in version 2.0.11 |
please look morę for the issues
…On sab 5 ago 2023, 11:56 PM Michael Li ***@***.***> wrote:
The problem persists in version 2.0.11
—
Reply to this email directly, view it on GitHub
<#4736 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A4JIPN7IKXUALUCU2MGWZF3XT26RFANCNFSM4WLDDWAQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
esp32 core 2.0.14 fixes the problem. |
Hello, I close this because the issue seems fixed. Also, this report contains the release we no longer support. Please try the new versions and in case the issue persists, feel free to reopen it. Thanks |
Hardware:
Board: DOIT ESP32 DEVKIT V1
Core Installation version: 1.0.4
IDE name: Platform.io
Flash Frequency: Can't tell (Crystal is 40MHz?)
PSRAM enabled: Can't tell
Upload Speed: 921600
Computer OS: Mac OSX
Description:
After reading the http response line with
WiFiClient::readBytesUntil()
callingWiFiClient::flush()
hangs indefinitely. Doesn't always happen, best guess is it depends on response length. First noticed with 204 No Content response from an influxdb server.Sketch:
Debug Messages:
The text was updated successfully, but these errors were encountered: