From: Damyan Ivanov Date: Sat, 22 Dec 2018 07:29:33 +0000 (+0000) Subject: put a 30 seconds timeout on network operations X-Git-Tag: v0.3~170 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=7d6fd4b4e3bfc08ee9c72a1d595b284df2517e59;p=mobile-ledger.git put a 30 seconds timeout on network operations --- 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; }