From d09cbef9a73b30b7da56ccbd6ee2558991d2f9cb Mon Sep 17 00:00:00 2001 From: Tom Nichols Date: Fri, 9 Jul 2010 17:23:02 -0400 Subject: catch other DNS errors that might occur and fallback to JID domain. --- sleekxmpp/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sleekxmpp') 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 -- cgit v1.2.3