Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,27 @@ private static void processUrl(Context c, String urlStr) throws IOException, SQL
URL url = new URL(urlStr);
conn = url.openConnection();

/*
Set live connection timeout to a low value.
If the responses are slow we are fine to wait until a better time.
*/
conn.setConnectTimeout(1000);
conn.setReadTimeout(1000);

// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while (rd.readLine() != null) ;

rd.close();
if (((HttpURLConnection) conn).getResponseCode() != 200) {
log.error("IRUS server responded with code " + ((HttpURLConnection) conn).getResponseCode() + " : " + urlStr);
ExportUsageEventListener.logfailed(c, urlStr);
} else if (log.isDebugEnabled()) {
log.debug("Successfully posted " + urlStr + " on " + new Date());
}
} catch (Exception e) {
log.error("Failed to send url to tracker URL: " + urlStr);
}
catch (Exception e) {
log.error("Failed to send url to tracker URL: " + urlStr + " - " + e.getMessage());
ExportUsageEventListener.logfailed(c, urlStr);
}
}
Expand All @@ -361,6 +370,13 @@ private static void tryReprocessFailed(Context context, OpenURLTracker tracker)
try {
URL url = new URL(tracker.getUrl());
conn = url.openConnection();

/*
Set retry connection timeout to a higher value.
*/
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);

BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while (rd.readLine() != null) ;
rd.close();
Expand Down