使用 Apache HttpClient,为什么我的连接超时不起作用?
我的 httpclient 实现在调用 doGetConnection() 时偶尔会引发异常。 但是,我设置了以下超时,
_moHttpClient.setHttpConnectionFactoryTimeout(30000);
看起来几乎就像我的超时没有被接收。 是否还有其他地方需要设置超时以确保这种行为不会再次发生
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你抛出了什么异常?
不要忘记您有两个超时需要更改/检查。 从 HttpConnectionParams 中
,您可以控制等待连接到服务器的时间,以及套接字上的操作在超时之前需要多长时间。
What exception are you getting thrown ?
Don't forget you have two timeouts to change/check. From
HttpConnectionParams
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.
我想知道为什么我设置了两个不同的 SoTimeouts。 也许我想找出哪一个实际上是活跃的,因为我在使用它时遇到了和你一样的问题。
上面的内容现在是我们这里的实时代码,但我不能说它是否有效,因为它是正确的,或者因为上帝正在对我微笑(而另一端通常总是可用的)。
I wonder why I have two different SoTimeouts set. Maybe I was trying to find out which one was actually active, as I had the same problems as you when I used it.
The above is in live code at our place right now, but I cannot say whether it works because it's correct, or because providence is smiling down on me (and the other end is usually always available).
默认情况下,此选项适用于所有 HttpClient。
这是针对特定 httpclient 的。
This one is for all HttpClient by default.
And this one is for a particular httpclient.