Skip to main content
Commonmark migration
Source Link

##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)

##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)

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)

deleted 1 characters in body
Source Link

##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, ana 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)

##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, an 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)

##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)

added exception type
Source Link
jjnguy
  • 3k
  • 15
  • 14

##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, an 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)

##Timeout Example

If you find that a response is taking too long for your app, you can set a timeout on the request.

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)

##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, an 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)

Source Link
jjnguy
  • 3k
  • 15
  • 14
Loading