From 7d6fd4b4e3bfc08ee9c72a1d595b284df2517e59 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 22 Dec 2018 07:29:33 +0000 Subject: [PATCH] put a 30 seconds timeout on network operations --- app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java b/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java index 8386bbff..44a7eb9d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/NetworkUtil.java @@ -26,6 +26,7 @@ import java.net.HttpURLConnection; 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", ""); @@ -43,6 +44,8 @@ public final class NetworkUtil { http.setRequestProperty("Accept-Charset", "UTF-8"); http.setInstanceFollowRedirects(false); http.setUseCaches(false); + http.setReadTimeout(thirtySeconds); + http.setConnectTimeout(thirtySeconds); return http; } -- 2.39.5