From ba1a8e9551a390e88f99119791c30e93aaf34d83 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 8 Sep 2018 18:03:10 +0000 Subject: [PATCH] Increase network timeout to 60 seconds --- .../java/eu/faircode/email/MessageHelper.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 6ab5b5edd6..7a202e4e87 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -61,6 +61,8 @@ public class MessageHelper { private MimeMessage imessage; private String raw = null; + private final static int NETWORK_TIMEOUT = 60 * 1000; // milliseconds + static Properties getSessionProperties(Context context, int auth_type) { Properties props = new Properties(); @@ -72,9 +74,9 @@ public class MessageHelper { props.put("mail.imaps.starttls.enable", "false"); // TODO: make timeouts configurable? - props.put("mail.imaps.connectiontimeout", "60000"); - props.put("mail.imaps.timeout", "60000"); - props.put("mail.imaps.writetimeout", "60000"); // one thread overhead + props.put("mail.imaps.connectiontimeout", Integer.toString(NETWORK_TIMEOUT)); + props.put("mail.imaps.timeout", Integer.toString(NETWORK_TIMEOUT)); + props.put("mail.imaps.writetimeout", Integer.toString(NETWORK_TIMEOUT)); // one thread overhead props.put("mail.imaps.connectionpooltimeout", Integer.toString(3 * 60 * 1000)); // default: 45 sec @@ -94,9 +96,9 @@ public class MessageHelper { props.put("mail.smtps.starttls.required", "false"); props.put("mail.smtps.auth", "true"); - props.put("mail.smtps.connectiontimeout", "20000"); - props.put("mail.smtps.writetimeout", "20000"); // one thread overhead - props.put("mail.smtps.timeout", "20000"); + props.put("mail.smtps.connectiontimeout", Integer.toString(NETWORK_TIMEOUT)); + props.put("mail.smtps.writetimeout", Integer.toString(NETWORK_TIMEOUT)); // one thread overhead + props.put("mail.smtps.timeout", Integer.toString(NETWORK_TIMEOUT)); props.put("mail.smtp.ssl.checkserveridentity", "true"); props.put("mail.smtp.ssl.trust", "*"); @@ -104,9 +106,9 @@ public class MessageHelper { props.put("mail.smtp.starttls.required", "true"); props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.connectiontimeout", "20000"); - props.put("mail.smtp.writetimeout", "20000"); // one thread overhead - props.put("mail.smtp.timeout", "20000"); + props.put("mail.smtp.connectiontimeout", Integer.toString(NETWORK_TIMEOUT)); + props.put("mail.smtp.writetimeout", Integer.toString(NETWORK_TIMEOUT)); // one thread overhead + props.put("mail.smtp.timeout", Integer.toString(NETWORK_TIMEOUT)); props.put("mail.imaps.peek", "true"); //props.put("mail.imaps.minidletime", "5000");