From 38efb84690f5ed46ad34b0a5cb27e63da73394bd Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 28 Mar 2014 19:00:01 +0100 Subject: [PATCH] treat dns timeouts as temporary. also increased timeout --- src/eu/siacs/conversations/utils/DNSHelper.java | 6 +++--- src/eu/siacs/conversations/xmpp/XmppConnection.java | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/eu/siacs/conversations/utils/DNSHelper.java b/src/eu/siacs/conversations/utils/DNSHelper.java index dbdd2648f..3197acb1f 100644 --- a/src/eu/siacs/conversations/utils/DNSHelper.java +++ b/src/eu/siacs/conversations/utils/DNSHelper.java @@ -31,7 +31,7 @@ public class DNSHelper { ip = InetAddress.getByName(value); servers.add(value); Bundle result = queryDNS(host, ip); - if (!result.containsKey("error")) { + if (!result.containsKey("error")||("nosrv".equals(result.getString("error")))) { return result; } } @@ -80,7 +80,7 @@ public class DNSHelper { DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); - datagramSocket.setSoTimeout(3000); + datagramSocket.setSoTimeout(7000); //die sieben ist meine zahl datagramSocket.receive(receivePacket); if (receiveData[3] != -128) { namePort.putString("error", "nosrv"); @@ -117,7 +117,7 @@ public class DNSHelper { } } catch (IOException e) { Log.d("xmppService", "io execpiton during dns"); - namePort.putString("error", "nosrv"); + namePort.putString("error", "timeout"); return namePort; } } diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index e265b9976..a32256ff4 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -123,6 +123,11 @@ public class XmppConnection implements Runnable { packetCallbacks.clear(); this.changeStatus(Account.STATUS_CONNECTING); Bundle namePort = DNSHelper.getSRVRecord(account.getServer()); + if ("timeout".equals(namePort.getString("error"))) { + Log.d(LOGTAG,account.getJid()+": dns timeout"); + this.changeStatus(Account.STATUS_OFFLINE); + return; + } String srvRecordServer = namePort.getString("name"); int srvRecordPort = namePort.getInt("port"); if (srvRecordServer != null) {