]> git.ktnx.net Git - mobile-ledger.git/commitdiff
put a 30 seconds timeout on network operations
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 22 Dec 2018 07:29:33 +0000 (07:29 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 22 Dec 2018 07:29:33 +0000 (07:29 +0000)
app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java

index 8386bbff057b85fc2cfac0bb6e6d946985ca619d..44a7eb9db579a539388aaf83ad38c7da708d5857 100644 (file)
@@ -26,6 +26,7 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 
 public final class NetworkUtil {
 import java.net.URL;
 
 public final class NetworkUtil {
+    private static final int thirtySeconds = 30000;
     public static HttpURLConnection prepare_connection(SharedPreferences pref, String path) throws
             IOException {
         final String backend_url = pref.getString("backend_url", "");
     public static HttpURLConnection prepare_connection(SharedPreferences pref, String path) throws
             IOException {
         final String backend_url = pref.getString("backend_url", "");
@@ -43,6 +44,8 @@ public final class NetworkUtil {
         http.setRequestProperty("Accept-Charset", "UTF-8");
         http.setInstanceFollowRedirects(false);
         http.setUseCaches(false);
         http.setRequestProperty("Accept-Charset", "UTF-8");
         http.setInstanceFollowRedirects(false);
         http.setUseCaches(false);
+        http.setReadTimeout(thirtySeconds);
+        http.setConnectTimeout(thirtySeconds);
 
         return http;
     }
 
         return http;
     }