質問

I want to increase timeout to 5 minutes because one minute is not enough to receive response.

I ahve tried this two approaches:

        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, 80000);
        HttpConnectionParams.setSoTimeout(httpParameters, 80000);



        DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);


        if (isNetworkAvailable()) {
            createRequest();
            HttpResponse response = httpClient.execute(request);
            final int code = response.getStatusLine().getStatusCode();

        AndroidDefaultClient client = AndroidDefaultClient.newInstance("tets");
        HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 5* 60 *1000);
        HttpConnectionParams.setSoTimeout(httpClient.getParams(), 5* 60 *1000);

Unfortunatly the timeout remains the same, but in case when I make it smaller, e.g. 10000, it works fine. Could you please help me to figure out with this issue?

役に立ちましたか?

解決

The Javadoc is incorrect on this point. The default connection timeout is platform-dependent, around a minute, and cannot be increased, only decreased.

他のヒント

Are you testing on an emulator? Perhaps you need to increase the adb connection timeout as mentioned here.

Or you might need to re-order your params and client code to have the params come first as talked about here.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top