##Timeout Example
Timeout Example
If you find that a response is taking too long for your app, you can set a timeout on the request.
If a timeout occurs, a java.net.SocketTimeoutException
is thrown. The default timeout is 0
which means infinite, so you don't have to worry about the exception if you never set a timeout.
StackWrapper sw = new StackOverflow();
// Set the timeout globally (1ms is way too short)
// But you will get to see the exception generated
HttpClient.setTimeout(1); // You shouldn't use 1, it will always timeout
sw.getUserById(2598);
So, instead of waiting for the response forever, you can time it out, and ask the user to try again later.
(This is very similar to how you would set the proxy server like in the proxy example)