pyst2
pyst2 copied to clipboard
Error when running show_channels.py
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
The script appears to 'Logoff' twice. Asterisk closes the TCP connection before the second logoff action is completed, so pyst2 shows the above error.
Commenting out Line 22 of show_channels.py seems to fix the issue. I believe it's caused by Logoff being actioned twice.
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.