views:

78

answers:

2

Is there any way to fire an event if HttpURLConnection has timeout before complete?

+2  A: 

There is no built-in timeout for this. What I do is to use a different thread and interrupt the thread after the timeout.

It's easier to use FutureTask for this. See my answer to this question,

http://stackoverflow.com/questions/1247390/java-native-process-timeout/1249984#1249984

ZZ Coder
Yes there is, see my answer.
EJP
That's socket timeout, only fires when you have network problem.
ZZ Coder
+1  A: 

URLConnection.setConnectTimeout() URLConnection.setReadTimeout()

@since 1.5

EJP