简体   繁体   中英

How to resolve org.apache.http.conn.ConnectTimeoutException in Http Request to another server?

I am using HttpClient to handling http requests and when I try to contect with my target server I am getting a error as

org.apache.http.conn.ConnectTimeoutException: Connect to prdalonegk.alonegk.com:9090 timed out

where prdalonegk.alonegk.com:9090 is my xmpp server

Make sure the host prdalonegk.alonegk.com is reacheable

ping prdalonegk.alonegk.com

and that it is can accept connections on port 9090 (firewall).

If all is ok, then try to increase the connection timeout:

RequestConfig.Builder requestBuilder = RequestConfig.custom();
requestBuilder = requestBuilder.setConnectTimeout(3000L); /* in ms */

Please refere to the request builder javadocs for all the settings you may provide.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM