summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/core/core.py1
-rw-r--r--poezio/core/handlers.py14
2 files changed, 12 insertions, 3 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py
index bcc64d1a..e4f4687d 100644
--- a/poezio/core/core.py
+++ b/poezio/core/core.py
@@ -62,6 +62,7 @@ class Core(object):
# of being displayed on the screen and exiting the program.
sys.excepthook = self.on_exception
self.connection_time = time.time()
+ self.last_stream_error = None
self.stdscr = None
status = config.get('status')
status = POSSIBLE_SHOW.get(status, None)
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index 484f7378..e1e3b4b1 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -901,6 +901,7 @@ class HandlerCore:
"""
self.core.information("Connection to remote server failed: %s" % (error,), 'Error')
+ @asyncio.coroutine
def on_disconnected(self, event):
"""
When we are disconnected from remote server
@@ -913,9 +914,14 @@ class HandlerCore:
tab.disconnect()
msg_typ = 'Error' if not self.core.legitimate_disconnect else 'Info'
self.core.information("Disconnected from server.", msg_typ)
- if not self.core.legitimate_disconnect and config.get('auto_reconnect', True):
- self.core.information("Auto-reconnecting.", 'Info')
- self.core.xmpp.start()
+ if self.core.legitimate_disconnect or not config.get('auto_reconnect', True):
+ return
+ if (self.core.last_stream_error and
+ self.core.last_stream_error[1]['condition'] in ('conflict', 'host-unknown')):
+ return
+ yield from asyncio.sleep(1)
+ self.core.information("Auto-reconnecting.", 'Info')
+ self.core.xmpp.start()
def on_stream_error(self, event):
"""
@@ -923,6 +929,8 @@ class HandlerCore:
"""
if event and event['text']:
self.core.information('Stream error: %s' % event['text'], 'Error')
+ if event:
+ self.core.last_stream_error = (time.time(), event)
def on_failed_all_auth(self, event):
"""