-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
How to diagnose the infamous read error 4? #1379
Comments
Thanks for the feedback. Unfortunately I can't give you any help unless it can be reproducible on my machine. Also since this is my personal after work project, I don't give any support. Thanks for your understanding. :) |
I was able to reproduce the error in my local environment, simulating the web service by sending the same payload for the error case, as was captured by SoapUI in its raw HTTP log. Despite being closed, I think that this may be of help to other users of the Client API. I managed to discover that using Chunked for the transfer-encoding header caused the problem Read Error 4, and this happened because the body of the request did not have the correct data-size markers for each chunk, it seems that SoapUI and Curl are permissive regarding this, I was able to receive the response with Curl despite de Chunk-encoding not being correct, but httplib can't. As soon as the format was fixed with the chunk sizes and all the CRLF and the end chunk 0-size, etc, etc, it worked. I think that the "Read Error" message could be enriched with very few more details, like "bad chunk format", it would save hours of diagnostics. Regards. |
Thanks for the fine report! Could you show me more detail of the incorrect format that the server produces? |
This was the string I did sent with a plan epoll-server to emulate the SOAP server, it's based on the tracelog captured by SoapUI for the case in question: ` inline std::string get_resp_body2() noexcept {
} ` If I remove any of the chunk-length markers in the body, then I can reproduce the problem on the httplib client, the function that processes the chunked content will fail. If I remove the "Transfer-Encoding: chunked" then it will not fail, I guess it goes via the Content-Without-Length code path. Curl did receive the response but it also did print some warnings. I am invoking this service without problem, this case has the peculiarity that the response is a bit longer than most of the cases, maybe the server they use has a bug and for certain cases it won't format the output in the right way for chunked encoding, that's my guess, because I did not see any other source of Read Errror 4 in httplib client API. |
I can confirm the following with the latest master version of httplib when using chunked encoding: if the POST payload does not end with ` 0\r\n\r\n ` ` 0\r\n ` I changed line 3441 of method read_content_chunked() and it worked, for well-formed chunked content as well as my case above with a single CR LF at the end. `
` I just added the comparison with "" empty string. Regards. |
Thanks for the information. When I have time, I'll see the code if cpp-httplib can return more meaningful error core rather than Read Error 4. |
I'll add my findings to this issue. I have a global
I have called So summarized this seems to be timing related on my end. Maybe something to do with timeouts? |
@oysteinmyrmo, thanks for the report. It has nothing to do with this issue, but it may be related to #1481. Could you try with the latest httplib. in the master branch to see if it fixes your problem? Thanks! EDIT on 9/7/2024: This could be related to #1801. If so, you can fix it by setting |
@mcordova1967 I changed cpp-httplib to allow chunked transfer encoding data without the final CRLF. The pseudo-code in the RFC9112 code also doesn't handle the CRLF. So it seems OK. |
I have an httplib client that invokes a single web service, but with certain data in the response, I receive error 4, the problem is... SoapUI does not have a problem invoking the same service with the same inputs and receiving the same response. I already discarded timeout, the headers look the same for all the cases including the bad one, and the body too, except it is bigger in the case that fails, but not that much.
I know that error 4 can be triggered by a problem parsing the headers or the body, but I wonder if the people who wrote that code could give me a hint about where to look, I see no DEBUG traces to enable, so where can I place some stdout in order to track or trap the thing that causes de Read Error 4, it is just that it looks so normal on Soap UI console! and it is only this case that fails with httplib.
Running with debugger is not an option, it's a production setup in a remote area, I have no remote access, I just can send a new EXE and they will send me the resulting output.
I suspect a CR or LF missing here or there, but where? the fact that SoapUI has no trouble makes it look like a bug on my side.
Any advice will be much appreciated. Keep in mind that the same service is being invoked without problem, receiving the same headers for all the cases. Content is chunked, no content length in headers.
Regards
The text was updated successfully, but these errors were encountered: