Android: AndroidHttpClient - how to set timeout?

后端 未结 5 1014
闹比i
闹比i 2020-12-11 04:38

I have followed the instructions of kuester2000\'s answer, but my timeout settings don\'t seem to work.

try
{
    int timeout = 3000;
    URL myURL = //some          


        
5条回答
  •  青春惊慌失措
    2020-12-11 04:59

    The other option to set on the client itself:

    AndroidHttpClient client = AndroidHttpClient.newInstance("Client V/1.0");
    HttpConnectionParams.setConnectionTimeout(this.client.getParams(), 3000);
    HttpConnectionParams.setSoTimeout(this.client.getParams(), 5000);
    

    This should result in those particular params being set...

    HTH

提交回复
热议问题