From f919f433bc0d946ecee1c77f35162181c7cb09af Mon Sep 17 00:00:00 2001 From: gitYord Date: Sun, 21 Sep 2014 14:07:32 +0200 Subject: [PATCH] SmackException while connecting in Listener null #29 - do two attempts to double the packet timeout --- src/de/adornis/Notifier/Listener.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/de/adornis/Notifier/Listener.java b/src/de/adornis/Notifier/Listener.java index ddf4fef..e5e2eb7 100644 --- a/src/de/adornis/Notifier/Listener.java +++ b/src/de/adornis/Notifier/Listener.java @@ -294,10 +294,23 @@ protected Void doInBackground(Void... params) { try { connect(); } catch (SmackException.NoResponseException e1) { - MainInterface.log("Couldn't log in with longer timeout either, giving up."); - e1.printStackTrace(); + MainInterface.log("NoResponseException while connecting in Listener " + e.getMessage()); + // probably got a timeout, try with bigger timeout + conn = new XMPPTCPConnection(MainInterface.getConfig(prefs.getAppUser().getDomain(), 5222)); + MainInterface.log("Retrying with package timeout of " + conn.getPacketReplyTimeout() * 2 + " instead of " + conn.getPacketReplyTimeout()); + conn.setPacketReplyTimeout(conn.getPacketReplyTimeout() * 2); + try { + connect(); + } catch (SmackException.NoResponseException e2) { + MainInterface.log("Couldn't log in with longer timeout either, giving up."); + e2.printStackTrace(); + } catch (Exception ignore) { + MainInterface.log("Some other error happened now o.0"); + } + getApplicationContext().sendBroadcast(new Intent("LISTENER_CONNECTED")); + disconnect(); } catch (Exception ignore) { - MainInterface.log("Some other error happened now o.0"); + MainInterface.log("Some other error hap SmackException while connecting in Listener null #29 pened now o.0"); } getApplicationContext().sendBroadcast(new Intent("LISTENER_CONNECTED")); disconnect();