-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
V2.4.2 fails regularly when sending "Connection: close" on client.print (GET... #5058
Comments
Please provide an MCVE and give more details about its behavior. |
I can confirm this. I updated to 2.4.2 because I had issues to get the WIFI_AP mode to run stable. My web pages exceed the max size of 2920 bytes, therefore I send them in 3 chunks. The header starts with: "HTTP/1.1 200 OK\n\Content-Type: text/html\n\Connection: close\n\n" followed by the page content itself.
With 2.4.2 the web page is broken (contains only parts of the last client.print() call for the body). I reverted to 2.4.0rc2 and everything is fine again without changing the sketch. To me it looks like in 2.4.2 client.stop(); works asynchrounus and does not wait for the last client.print() to be completed. Btw: My page uses websockets. These start very delayed with 2.4.2 in 2.4.0rc2 it is like expected. |
Maybe related to #5021. full MCVE is welcome. |
Could you please confirm whether calling |
Same problem here. client.flush() right before client.stop() did NOT change anything. Problem still exists. |
This issues looks like the other above mentioned #5021 which is a user error with a sketch that worked with previous versions (unknown reason so far) but badly handling http protocol. Browser's header was not fully read (It can be fixed by at least honoring browser by reading its full http header before closing the connection). Without MCVE, we can't help. We need more details. |
I've posted this short MCVE Sketch also in #5021.
|
Same observation as #5021
It's working and shows:
meaning that you read '\r\n\r' and not the final '\n' Yet,
|
Hi David you are welcome. I also prepared a small scetch stripped down to the basic needs. It opens a WiFi_STA connection. The IP given in the serial monitor keyed in into a browser adress field should show up a web page with a table with 30 rows and the text 'Web page complete.' at the end. I'm using the arduino IDE 1.8.5. The target is a generic ESP-01, but is reproduceable with other targets, like WeMos mini too. With 2.4.0 (rc2) the page shows up fine in 2.4.2 the table is broken at coincidentally positions due to missing content.
|
Some comments here:
|
@DonKracho same issue (read the full header until an empty line terminated by @ALL Why not use the integrated WebServer library ? |
hi - being the originator of this issue I'm somewhat confused with the conclusion reached in this thread. Is this in fact an error in V2.4.2 core ? I'm using very standard method of reading header information before I read the body. @devyte, not 100% what you mean by "About backwards compatibility, we try to maintain it as much as possible in minor releases, but we don't keep bugs around to service apps that rely on them. In other words, if an app happens to work due to a bug in our core, and then that bug gets fixed, expect to have to update the app." Code below. Using V2.4.2 line labelled [LINE100] sometimes returns a false BUT it works perfectly in V2.4.1
|
@mars000 The
It is now since #4626:
Your MCVE not beeing complete, I can't reproduce neither say more about this. Please provide an MCVE, or give as much details as you can.
This is not clear enough ... Well, after re-reading, if the connection is supposed to close at any time, but there are still data to read, use
@ALL please provide details of your issues, we are here to help you with the core, and we are not paid for that, help us help you ! |
@d-a-v did you have the chance to try my scetch? Moving the client.flush() line or inserting your suggested code line with the client.read() before the client.stop() does not solve the issue. This is the complete http get request of a current chrome browser:
client.readStringUntil('\r'); breaks after the first line is read. If there is a '\n' depends on the client OS. To clear the entire input queue at least a client.flush() has to be done. One client.read() just reads one more char from the input and there remains a lot of input in the queue. The Chrome browser just sends out all this stuff and really does not care if anybody is reading it! Chrome just waits for a well formed response. If this does not come in time it shows up a timeout. The client.read() just puts a little delay before the client.stop() and therfore may solve the issue for small web pages. Intentionally I made my web page response much longer (at least it has to be larger than 1460 bytes). In order to get my code to run 'stable' I have to put a delay of minimal 75us before the client.stop(). My conclusion: The behavior of client.print() or client.stop() has changed somewhere between 2.4.0(rc2) and 2.4.2 Either the clinet.print() does return before it is finished or client.stop() does not wait for all transmission activites to be finished. |
edit Once you have read all the header and written your answer, add a |
Alright, per @d-a-v 's analysis, it looks to me like the user app was relying on a previous core bug which has since been fixed. The fact that client.readStringUntil("\r") was used to detect \r\n\r\n certainly points in that direction. |
@d-a-v
instead of just.....
|
What got me confused was this example: |
@d-a-v Working code:
and the same thing refactored using the ESP8266WebServer class is working with 2.4.2 too:
|
Hi
I'm using ESP8266 V2.4.2
Noticed that when I upgraded from V2.4.1 that regularly if I use the "close" connection vs "open" it fails to read HTTP headers correctly. Worked all fine on V2.4.0 and V2.4.1
Not sure what the issue it. As said - works perfectly if I use Connection: open on V2.4.2 but not "Connection: close"
The call I'm using is:
----------------------------- Delete below -----------------------------
If your issue is a general question, starts similar to "How do I..", is related to 3rd party libs, or is related to hardware, please discuss at a community forum like esp8266.com.
INSTRUCTIONS
If you do not follow these instructions, your issue may be dismissed.
https://arduino-esp8266.readthedocs.io/en/latest/Troubleshooting/stack_dump.html
https://arduino-esp8266.readthedocs.io/en/latest/Troubleshooting/debugging.html
----------------------------- Delete above -----------------------------
Basic Infos
Platform
Settings in IDE
Problem Description
Detailed problem description goes here.
MCVE Sketch
Debug Messages
The text was updated successfully, but these errors were encountered: