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

Error when running show_channels.py #16

Open
marrold opened this issue Nov 3, 2015 · 1 comment
Open

Error when running show_channels.py #16

marrold opened this issue Nov 3, 2015 · 1 comment

Comments

@marrold
Copy link

marrold commented Nov 3, 2015

I get the following error when attempting to run the example, show_channels.py.

Python 2.6.6
CentOS 6.5
Asterisk 11.14.2

python show_channels.py

Success
SIP/6606-00000018!lhs-pager-conference!s!4!Up!ConfBridge!1234,pagerbridge,pagerparticipant,!6606!!!3!133!(None)!1446585827.34
--END COMMAND--

Traceback (most recent call last):
File "show_channels.py", line 35, in
manager.close()
File "/usr/lib/python2.6/site-packages/pyst2-0.4.6-py2.6.egg/asterisk/manager.py", line 483, in close
self.logoff()
File "/usr/lib/python2.6/site-packages/pyst2-0.4.6-py2.6.egg/asterisk/manager.py", line 524, in logoff
response = self.send_action(cdict)
File "/usr/lib/python2.6/site-packages/pyst2-0.4.6-py2.6.egg/asterisk/manager.py", line 276, in send_action
raise ManagerSocketException(0, 'Connection Terminated')
asterisk.manager.ManagerSocketException: (0, 'Connection Terminated')
Exception in thread Thread-2 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner
File "/usr/lib64/python2.6/threading.py", line 484, in run
File "/usr/lib/python2.6/site-packages/pyst2-0.4.6-py2.6.egg/asterisk/manager.py", line 425, in event_dispatch
File "/usr/lib64/python2.6/Queue.py", line 179, in get
File "/usr/lib64/python2.6/threading.py", line 274, in notify
<type 'exceptions.TypeError'>: 'NoneType' object is not callable

The script appears to 'Logoff' twice. Asterisk closes the TCP connection before the second logoff action is completed, so pyst2 shows the above error.
ami

Commenting out Line 22 of show_channels.py seems to fix the issue. I believe it's caused by Logoff being actioned twice.

@tuxpowered
Copy link
Contributor

I took a quick look at this, it appears your issue asterisk.manager.ManagerSocketException: (0, 'Connection Terminated') can be avoided by catching the exception.

The logoff is executed early in the script, but when the manager.close() is executed it saw that an instance was running and attempted to logoff that instance, but the connection got closed before it could complete. Thus the asterisk.manager.ManagerSocketException: (0, 'Connection Terminated') was raised.
You can add a try: except: block in the finally: section to overcome this error, but at this time I do not see any issue with the manager event itself relating to this.

Remember that the asterisk manager interface is not the most robust when making multiple connections.
In testing it is rather easy to get connection errors simply by sending several requests back to back.

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

No branches or pull requests

2 participants