kan man sætte timeout på en HttpUrlConnection
Kan man sætte timeout på en Url connection ??Mit problem er, at
"c = (HttpURLConnection) pollUrl.openConnection();"
nogle gange hænger, dvs at der returneres ikke nogen responsecode ??
Tråden står bare og venter.....
private String myStartSession() throws IOException {
String cookie = null;
String pollUrlStr = "http://" + HOST_NAME + "/" + POLL_URL;
URL pollUrl = new URL(pollUrlStr);
HttpURLConnection c = null;
try {
c = (HttpURLConnection) pollUrl.openConnection();
logger.debug("OpenConnection, Responscode: " +c.getResponseCode());
if (c.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
logger.debug("Responscode: " + c.getResponseCode());
throw new IOException();
}
cookie = c.getHeaderField("set-cookie");
if (cookie == null) {
throw new IOException();
}
return cookie;
} catch (IOException e) {
throw new SJConnectionException();
}
}
