From c4f6e51223001898fbf0c882764dd09a181862e7 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 31 Aug 2013 22:29:41 +0300 Subject: [PATCH] Make FonBot more reliable Reading from sockets now times out after 24 minutes, fixing the major bug when FonBot would stop responding to commands after some time of not using it. The other change in this commit is that ExecutableRunnables are retried at each service ping. --- src/ro/ieval/fonbot/FonBotMainService.java | 2 ++ src/ro/ieval/fonbot/HttpCallExecutableRunnable.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/ro/ieval/fonbot/FonBotMainService.java b/src/ro/ieval/fonbot/FonBotMainService.java index 8e8d67a..4da70cc 100644 --- a/src/ro/ieval/fonbot/FonBotMainService.java +++ b/src/ro/ieval/fonbot/FonBotMainService.java @@ -178,6 +178,8 @@ public final class FonBotMainService extends Service { longPollThread.start(); } + ExecutableRunnable.retryTasks(); + final boolean runForeground=PreferenceManager.getDefaultSharedPreferences(this).getBoolean("foreground", false); if(!runForeground) stopForeground(true); diff --git a/src/ro/ieval/fonbot/HttpCallExecutableRunnable.java b/src/ro/ieval/fonbot/HttpCallExecutableRunnable.java index 4781d61..0eda24a 100644 --- a/src/ro/ieval/fonbot/HttpCallExecutableRunnable.java +++ b/src/ro/ieval/fonbot/HttpCallExecutableRunnable.java @@ -133,6 +133,7 @@ public final class HttpCallExecutableRunnable extends ExecutableRunnable{ try { final URL url=Utils.getServerURL(toNonNull(context),toNonNull(path)); final HttpURLConnection conn=(HttpURLConnection) url.openConnection(); + conn.setReadTimeout(24*60*1000);//24 minutes if(data!=null){ conn.setDoOutput(true); conn.setFixedLengthStreamingMode(data.length); -- 2.39.2