Is there any way to fire an event if HttpURLConnection has timeout before complete?
2 Answers
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,
2 Comments
ZZ Coder
That's socket timeout, only fires when you have network problem.
user207421
completely incorrect. Connection timeout fires when you can't connect within the timeout, and read timeout fires if there is nothing to read within the timeout for any reason, including the server not sending anything.