Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asterisk disconnection and timeout were not correctly handled #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

desweemerl
Copy link

We noticed that when Asterisk was not able to respond, we got a BrokenPipeError which blocked further requests:

...
out = self._ami_client.send_action(SimpleAction('Command', Command=cmd)).response
File "/usr/lib/python3/dist-packages/asterisk/ami/client.py", line 142, in send_action
self.send(action)
File "/usr/lib/python3/dist-packages/asterisk/ami/client.py", line 146, in send
self._socket.send(bytearray(unicode(pack) + '\r\n', self.encoding))
BrokenPipeError: [Errno 32] Broken pipe

The proposed change will restart the socket either in case of BrokenPipeError or TimeoutError exceptions.

desweemerl and others added 2 commits January 7, 2025 15:32
BrokenPipeError was not recovered, preventing action from being sent.
Also socket was not reconnected when there was a connection timeout.
@sdefauw
Copy link
Contributor

sdefauw commented Jan 9, 2025

👍️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants