Skip to content Skip to sidebar Skip to footer

Getting Sockettimeoutexceptions Using Loopj Asynchttpclient... Is There A Timeout Value I Can Set?

When using the loopj AsyncHttpClient library, I keep getting java.net.SocketTimeoutExceptions when making requests (see below). Is there some timeout value I can set? Note: I'm pos

Solution 1:

I discovered that the AsyncHttpClient actually defaults to a 10 second timeout. If your request takes longer you'll see the SocketTimeoutException thrown.

Adjusting this is really simple. Just do the following:

finalintDEFAULT_TIMEOUT=20 * 1000;
AsyncHttpClientaClient=newAsyncHttpClient();
aClient.setTimeout(DEFAULT_TIMEOUT);
//... continue as normal

Edit: (thanks, Horkavlna!)

You can see the details of the method in the javadoc - http://loopj.com/android-async-http/doc/com/loopj/android/http/AsyncHttpClient.html#setTimeout(int)

Post a Comment for "Getting Sockettimeoutexceptions Using Loopj Asynchttpclient... Is There A Timeout Value I Can Set?"