Make FonBot more reliable
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 31 Aug 2013 19:29:41 +0000 (22:29 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 31 Aug 2013 19:29:41 +0000 (22:29 +0300)
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
src/ro/ieval/fonbot/HttpCallExecutableRunnable.java

index 8e8d67a0c535806b89f0e37a6eed6d46503dfe47..4da70cca45455e011d1d4d126509d41150ee3c48 100644 (file)
@@ -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);
index 4781d6161616e631a23d6489aac92ebf94ac1954..0eda24af98154dcc56f8864ab75b331691f588eb 100644 (file)
@@ -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);
This page took 0.010683 seconds and 4 git commands to generate.