I have an Android app that connects in a server searching for updates. If the server takes a long time to respond (+500ms), I have to finish my method and continue with the program.
I already set the readTimeout
and connectTimeout
to 500 ms, but even then my method are taking about 30 seconds in this line: c.connect();
This is my code:
HttpURLConnection c = (HttpURLConnection) updateUrl.openConnection();
c.setConnectTimeout(500);
c.setReadTimeout(500);
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect(); // the program stops here
What I need to do?