使用Apache HttpClient,为什么我的连接超时不起作用?

使用Apache HttpClient,为什么我的连接超时不起作用?

问题描述:

在调用doGetConnection()时,我的httpclient实现偶尔会抛出异常。但是,我有以下超时设置

My implementation of httpclient occasionally throws an exception when calling doGetConnection(). However, I have the following timeout set

_moHttpClient.setHttpConnectionFactoryTimeout(30000);

看起来我的超时几乎没有被提取。是否有其他地方我需要设置超时以确保不再发生此行为

it looks almost like my timeout is not being picked up. Is there anywhere else I need to set a timeout to ensure this behaviour does not re-occur

你被抛出什么异常?

不要忘记你有两次超时来更改/检查。从 HttpConnectionParams

Don't forget you have two timeouts to change/check. From HttpConnectionParams

setConnectionTimeout()
setSoTimeout()

因此您可以控制等待连接服务器的时间以及套接字上的操作时间可以在超时之前拍摄。

so you can control how long you wait for a connection to the server, and how long operations on the socket can take before timing out.