Asyhttpclient设置了超时,但是还是要很长时间才会响应连接失败

mcgradybryant
  • 62

请问下,Asyhttpclient使用setTimeOut方法设置了超时,为啥还是会等很长时间才会响应onFailure的方法

回复
阅读 1.9k
2 个回答
✓ 已被采纳

仔细看看文档,检查一下代码,注意以下几个方法的区别

setTimeout(int value)

Set both the connection and socket timeouts. By default, both are set to 10 seconds.



setConnectTimeout(int value)

Returns current connection timeout limit (milliseconds). By default, this is set to 10 seconds.



setMaxRetriesAndTimeout(int retries, int timeout)

Sets the maximum number of retries and timeout for a particular Request.

最好别用这个库了,已经过时了,用okhttp/retrofit

宣传栏