1. Cause of error:
When the resttemplate is used to call the third-party API, the local test is normal, but when it is deployed to the server, it will report: Dan, 19:06 org.springframework.web . client.ResourceAccessException : I/O error on POST request for "XXX": No route to host (Host unreachable); nested exception is java.net.NoRouteToHostException : no route to host (host unreachable) code>, at first, I thought that the timeout was not set, so I configured it through online methods
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setConnectTimeout(10*1000);
requestFactory.setReadTimeout(10*1000);
RestTemplate rest = new RestTemplate(requestFactory);
Deployment or error
2. Solutions
Finally, the interface setting the timeout time is replaced with httpcomponentsclienthttprequestfactory code> to solve the problem successfully
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setConnectTimeout(10*1000);
requestFactory.setReadTimeout(10*1000);
RestTemplate rest = new RestTemplate(requestFactory);
Read More:
- Disk BLK_ update_ request: I/O error
- Sync with Gradle for project ‘XXXX‘ failed: Connection timed out: connect
- Putty:Network error:Connection timed out
- [resolved] exception java.net.ConnectException : Error opening socket to server Connection timed out.
- In the HTML page request Ajax times 400 error, solve Yii submit post form 400 error, and Ajax post request 400 problem (example code)
- Ubuntu 20.04 GPG: KeyServer receive failed: connection timed out when installing ROS configuration key
- Error: JMeter monitors Linux system performance java.net.ConnectException : Connection timed out: connect
- Debian/Ubuntu uses proxy for gpg and apt-key-error resolution: gpg: keyserver receive failed: Connection timed out
- RTMP_Connect0, failed to connect socket. 110 (Connection timed out)
- [nodejs] error request aborted after request routing in post mode
- Troubleshooting of “disk I / O error” after startup
- coredns [ERROR] plugin/errors: 2 read udp : i/o timeout
- An I/O operation initiated by the Registry failed unrecoverably
- Synergy Ubuntu 18 + win7 timed out or new client is unresponsive
- java.sql.SQLException : IO error: socket read timed out!
- NBU recovery report error socket read failed: errno = 119-System call timed out
- java.sql.SQLException : IO exception: socket read timed out
- Jetty9 change post request length
- When feign is called, the solution of request method ‘post’ not supported appears
- esp32:A fatal error occurred: Timed out waiting for packet header