jfernandz / pyst2

A fork of the famous python pyst library for Asterisk.
139 stars 105 forks source link

asteriks authenticate problem #61

Open muhammetfaik opened 3 years ago

muhammetfaik commented 3 years ago

I run this code

"""
Example to get list of active channels
"""
import asterisk.manager
import sys

manager = asterisk.manager.Manager()

try:
    # connect to the manager
    try:
        manager.connect('localhost')
        manager.login('muhammet', '123456')

        # get a status report
        response = manager.status()
        print(response)

        response = manager.command('core show channels concise')
        print(response.data)

        manager.logoff()
    except asterisk.manager.ManagerSocketException as e:
        print ("Error connecting to the manager: %s" % e.strerror)
        sys.exit(1)
    except asterisk.manager.ManagerAuthException as e:
        print ("Error logging in to the manager: %s" % e.strerror)
        sys.exit(1)
    except asterisk.manager.ManagerException as e:
        print ("Error: %s" % e.strerror)
        sys.exit(1)

finally:
    # remember to clean up
    manager.close()

Add this line

[muhammet]
secret = 123456
deny = 0.0.0.0/0.0.0.0
permit = 192.168.0.0/255.255.255.0
read = all
write = all
writetimeout = 5000

in /etc/manager.conf file but I take this error :


Traceback (most recent call last):
  File "asteriksornek.py", line 27, in <module>
    print ("Error logging in to the manager: %s" % e.strerror)
AttributeError: 'ManagerAuthException' object has no attribute 'strerror'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "asteriksornek.py", line 35, in <module>
    manager.close()
  File "/home/mert/.local/lib/python3.8/site-packages/asterisk/manager.py", line 500, in close
    self.logoff()
  File "/home/mert/.local/lib/python3.8/site-packages/asterisk/manager.py", line 541, in logoff
    response = self.send_action(cdict)
  File "/home/mert/.local/lib/python3.8/site-packages/asterisk/manager.py", line 283, in send_action
    self._sock.write(command.encode('utf8','ignore'))
  File "/usr/lib/python3.8/socket.py", line 684, in write
    self._checkClosed()
ValueError: I/O operation on closed file.
ludovic-gasc commented 3 years ago

You might check the firewalls on client and host, or at least, check the TCP connexion content on port 5038 with wireshark, tshark or tcpdump

muhammetfaik commented 3 years ago

which do I write command ?

muhammetfaik commented 3 years ago

do you give something information ?

ldo commented 2 years ago

Two things: