Problem analysis and workaround for calling HttpClient [read] I/O error:read timed out

Source: Internet
Author: User
Tags http request

When sending an HTTP request using HttpClient, the server receives the transaction only after 3 seconds of basic time.


The logs are as follows:

2017-12-25 09:08:26,001 [http-nio-8080-exec-8] DEBUG o.a.h.wire-http-outgoing-322 >> "connection:keep-alive[\r ][\n] "
2017-12-25 09:08:26,001 [http-nio-8080-exec-8] DEBUG o.a.h.wire-http-outgoing-322 >> "user-agent: apache-httpclient/4.5.1 (java/1.8.0_144) [\r][\n] "
2017-12-25 09:08:26,001 [http-nio-8080-exec-8] DEBUG o.a.h.wire-http-outgoing-322 >> "expect:100-continue[\r][ \ n] "
2017-12-25 09:08:26,001 [http-nio-8080-exec-8] DEBUG o.a.h.wire-http-outgoing-322 >> "Accept-encoding:gzip, Deflate[\r][\n] "
2017-12-25 09:08:26,001 [http-nio-8080-exec-8] DEBUG o.a.h.wire-http-outgoing-322 >> "[\r][\n]"
2017-12-25 09:08:26,353 [nioeventloopgroup-700-1] DEBUG i.n.b.poolthreadcache-freed 1 thread-local buffer (s) from Threa D:nioeventloopgroup-700-1
2017-12-25 09:08:27,986 [nioeventloopgroup-701-1] DEBUG i.n.b.poolthreadcache-freed 2 thread-local buffer (s) from Threa D:nioeventloopgroup-701-1
2017-12-25 09:08:29,005 [http-nio-8080-exec-8] DEBUG o.a.h.wire-http-outgoing-322 << [read] I/O error:read timed Out

=============================================================================================================== ========


To this, looked up the source error message, also did not locate the cause of the problem. Later or by looking at the log, in the error before there is a section of "expect:100-continue[\r][\n", and then looked at the HTTP 1.0 and 1.1 protocol, and combined with the analysis of the packet capture, it dawned. HTTP 1.1 supports sending only header information (without any body information) and returns 100 if the server thinks the client has permission to request the server, otherwise 401. The client will only start sending the request body to the server if it accepts 100.


After that, you can send and receive an answer as soon as you change the HTTP protocol to 1.0


Reference: Https://www.ietf.org/rfc/rfc2616.txt

http://blog.csdn.net/kingcodexl/article/details/51306062

http://blog.csdn.net/linsongbin1/article/details/54980801


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.