summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java b/src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java
index 97b5f5a..492e371 100644
--- a/src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java
+++ b/src/main/java/org/openslx/dnbd3/status/poller/ServerPoller.java
@@ -33,13 +33,13 @@ public class ServerPoller
public Status update()
{
HttpURLConnection con = null;
- InputStream is;
+ InputStream is = null;
try {
con = (HttpURLConnection)new URL( this.server ).openConnection();
con.setRequestMethod( "GET" );
- con.setConnectTimeout( 1000 );
- con.setReadTimeout( 2000 );
+ con.setConnectTimeout( 2000 );
+ con.setReadTimeout( 4000 );
if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
return null;
@@ -47,8 +47,12 @@ public class ServerPoller
is = con.getInputStream();
} catch ( java.net.SocketTimeoutException e ) {
+ System.out.println( "Timeout " + this.server );
+ NanoHTTPD.safeClose( is );
return null;
} catch ( java.io.IOException e ) {
+ System.out.println( "IOException " + this.server );
+ NanoHTTPD.safeClose( is );
return null;
}
// Now read data
@@ -61,10 +65,17 @@ public class ServerPoller
}
NanoHTTPD.safeClose( isr );
NanoHTTPD.safeClose( is );
- NanoHTTPD.safeClose( con.getErrorStream() );
status.setAddress( address );
status.setTimestamp( System.currentTimeMillis() );
} catch ( Exception e ) {
+ try {
+ InputStream es = con.getErrorStream();
+ while ( es.read( buffer ) > 0 ) {
+ // Nothingness
+ }
+ NanoHTTPD.safeClose( es );
+ } catch ( Exception e2 ) {
+ }
e.printStackTrace();
status = null;
}