From: Marius Gavrilescu Date: Sat, 31 Aug 2013 19:29:41 +0000 (+0300) Subject: Make FonBot more reliable X-Git-Tag: 0.000_001~5 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=c4f6e51223001898fbf0c882764dd09a181862e7;p=fonbot.git 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. --- 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);