Commit 11b193fb authored by mathieui's avatar mathieui

Fix #3219, Fix #3220 (no connection loops on some stream errors)

Do not reconnect if the stream error is a conflict or an host-unknown;
also add a sleep(1) in order to not DoS the server if it loops on other
parent 04939cc6
......@@ -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)
......@@ -901,6 +901,7 @@ class HandlerCore:
self.core.information("Connection to remote server failed: %s" % (error,), 'Error')
def on_disconnected(self, event):
When we are disconnected from remote server
......@@ -913,9 +914,14 @@ class HandlerCore:
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')
if self.core.legitimate_disconnect or not config.get('auto_reconnect', True):
if (self.core.last_stream_error and
self.core.last_stream_error[1]['condition'] in ('conflict', 'host-unknown')):
yield from asyncio.sleep(1)
self.core.information("Auto-reconnecting.", 'Info')
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):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment