From 5371dd025a3c3b341c061d59f3c3d66cb07c0a2c Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sat, 4 Oct 2014 14:33:14 +0200 Subject: [PATCH] no dns retry after nosrv error --- src/eu/siacs/conversations/utils/DNSHelper.java | 7 ++----- src/eu/siacs/conversations/xmpp/XmppConnection.java | 6 +++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/eu/siacs/conversations/utils/DNSHelper.java b/src/eu/siacs/conversations/utils/DNSHelper.java index fd3b19534..3952ad049 100644 --- a/src/eu/siacs/conversations/utils/DNSHelper.java +++ b/src/eu/siacs/conversations/utils/DNSHelper.java @@ -30,17 +30,16 @@ public class DNSHelper { String dns[] = client.findDNS(); if (dns != null) { - // we have a list of DNS servers, let's go for (String dnsserver : dns) { InetAddress ip = InetAddress.getByName(dnsserver); Bundle b = queryDNS(host, ip); if (b.containsKey("name")) { return b; + } else if (b.containsKey("error") && "nosrv".equals(b.getString("error", null))) { + return b; } } } - - // fallback return queryDNS(host, InetAddress.getByName("8.8.8.8")); } @@ -164,10 +163,8 @@ public class DNSHelper { } } catch (SocketTimeoutException e) { - Log.d(Config.LOGTAG, "timeout during dns"); namePort.putString("error", "timeout"); } catch (Exception e) { - Log.d(Config.LOGTAG, "unhandled exception in sub project"); namePort.putString("error", "unhandled"); } return namePort; diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index b055e35a3..76cfa6037 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -166,8 +166,12 @@ public class XmppConnection implements Runnable { + ":" + srvRecordPort); socket = new Socket(srvRecordServer, srvRecordPort); } - } else { + } else if (namePort.containsKey("error") && "nosrv".equals(namePort.getString("error", null))) { socket = new Socket(account.getServer(), 5222); + } else { + Log.d(Config.LOGTAG,account.getJid()+": timeout in DNS resolution"); + changeStatus(Account.STATUS_OFFLINE); + return; } OutputStream out = socket.getOutputStream(); tagWriter.setOutputStream(out);