Skip to content

Commit

Permalink
Add HTTP connection timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
J4bbi committed Dec 8, 2020
1 parent 76a8d77 commit 14665a7
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ private static void processUrl(Context c, String urlStr) throws IOException, SQL
// Send data
URL url = new URL(urlStr);
conn = url.openConnection();
conn.setReadTimeout(5000);

// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
Expand All @@ -349,7 +350,12 @@ private static void processUrl(Context c, String urlStr) throws IOException, SQL
} else if (log.isDebugEnabled()) {
log.debug("Successfully posted " + urlStr + " on " + new Date());
}
} catch (Exception e) {
} catch(SocketTimeoutException ste) {
log.error("HTTP connection to IRUS server timed out: " + urlStr);
ExportUsageEventListener.logfailed(c, urlStr);
}
}
catch (Exception e) {
log.error("Failed to send url to tracker URL: " + urlStr);
ExportUsageEventListener.logfailed(c, urlStr);
}
Expand Down

0 comments on commit 14665a7

Please sign in to comment.