diff --git a/asterisk/ami/client.py b/asterisk/ami/client.py index 71abf7f..21e73dc 100644 --- a/asterisk/ami/client.py +++ b/asterisk/ami/client.py @@ -313,6 +313,11 @@ def try_reconnect(self): if response is not None and not response.is_error(): self.on_reconnect(self._ami_client, response) return True + except (BrokenPipeError): + self._ami_client._socket.close() + self._ami_client._socket = None + self._ami_client.connect() + self.try_reconnect() except: pass return False