summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-11-12 22:14:09 +0100
committermathieui <mathieui@mathieui.net>2014-11-12 22:22:20 +0100
commit3c06568ed57f2e41ca97693330d71b173f9b0c98 (patch)
tree13842f578c4c1fadf6cead09301e45d8ebbb5c51
parent68e35e631a184fd3bdbfaf1ecc1c7e1e8c079414 (diff)
downloadslixmpp-3c06568ed57f2e41ca97693330d71b173f9b0c98.tar.gz
slixmpp-3c06568ed57f2e41ca97693330d71b173f9b0c98.tar.bz2
slixmpp-3c06568ed57f2e41ca97693330d71b173f9b0c98.tar.xz
slixmpp-3c06568ed57f2e41ca97693330d71b173f9b0c98.zip
Let loop.create_connection do its getaddrinfo coroutine if there are no dns records left/available
-rw-r--r--slixmpp/xmlstream/xmlstream.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index d672c221..1b69967c 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -297,18 +297,21 @@ class XMLStream(object):
else:
if record:
host, address, port = record
+ self.address = (address, port)
self._service_name = host
else:
- self.event('connection_failed',
- 'No DNS record available for %s' % self.default_domain)
+ # No DNS records left, stop iterating
+ # and try (host, port) as a last resort
self.dns_answers = None
- return
try:
yield from loop.create_connection(lambda: self,
- address,
- port,
+ self.address[0],
+ self.address[1],
ssl=self.use_ssl)
+ except Socket.gaierror as e:
+ self.event('connection_failed',
+ 'No DNS record available for %s' % self.default_domain)
except OSError as e:
log.debug('Connection failed: %s', e)
self.event("connection_failed", e)