summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Nichols <tmnichols@gmail.com>2010-07-09 17:23:02 -0400
committerTom Nichols <tmnichols@gmail.com>2010-07-09 17:23:02 -0400
commitd09cbef9a73b30b7da56ccbd6ee2558991d2f9cb (patch)
tree11384c2ac004afe5419cd237f2d36e639595dd53
parent9c850f080d8000cb6462082a0468ec7fdbc46575 (diff)
downloadslixmpp-d09cbef9a73b30b7da56ccbd6ee2558991d2f9cb.tar.gz
slixmpp-d09cbef9a73b30b7da56ccbd6ee2558991d2f9cb.tar.bz2
slixmpp-d09cbef9a73b30b7da56ccbd6ee2558991d2f9cb.tar.xz
slixmpp-d09cbef9a73b30b7da56ccbd6ee2558991d2f9cb.zip
catch other DNS errors that might occur and fallback to JID domain.
-rw-r--r--sleekxmpp/__init__.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/sleekxmpp/__init__.py b/sleekxmpp/__init__.py
index 84c67bc5..dc847f30 100644
--- a/sleekxmpp/__init__.py
+++ b/sleekxmpp/__init__.py
@@ -36,6 +36,7 @@ srvsupport = True
try:
import dns.resolver
import dns.rdatatype
+ import dns.exception
except ImportError:
srvsupport = False
@@ -120,6 +121,9 @@ class ClientXMPP(basexmpp, XMLStream):
answers = dns.resolver.query("_xmpp-client._tcp.%s" % self.server, dns.rdatatype.SRV)
except dns.resolver.NXDOMAIN:
logging.debug("No appropriate SRV record found. Using JID server name.")
+ except dns.exception.DNSException:
+ # this could be a timeout or other DNS error. Worth retrying?
+ logging.exception("DNS error during SRV query for %s. Using JID server name.", self.server)
else:
# pick a random answer, weighted by priority
# there are less verbose ways of doing this (random.choice() with answer * priority), but I chose this way anyway