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

No event is being captured #49

Open
nouman-ux opened this issue Apr 12, 2022 · 8 comments
Open

No event is being captured #49

nouman-ux opened this issue Apr 12, 2022 · 8 comments

Comments

@nouman-ux
Copy link

#!/usr/bin/python
import os
import time

from asterisk.ami import AMIClient
from asterisk.ami import EventListener

def event_listener(event,**kwargs):
print(event)

client = AMIClient(address='127.0.0.1',port=5038)
future = client.login(username='astmanager',secret='Xn75CFbVfjRg71v')
if future.response.is_error():
raise Exception(str(future.response))

client.add_event_listener(event_listener)
try:
while True:
time.sleep(10)
except (KeyboardInterrupt, SystemExit):
client.logoff()

this code is running without error but shows no even on the terminal when I run it

@ettoreleandrotognoli
Copy link
Owner

Do you have more info about the astmanager user in your /etc/asterisk/manager.conf?
I'm asking to be sure that this user can receive events.

@nouman-ux
Copy link
Author

astmanager] ; this must be generated automatically
secret = Xn75CFbVfjRg71v
deny = 0.0.0.0/0.0.0.0
permit= 127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
writetimeout = 60000
this is the settings for this user

@nouman-ux
Copy link
Author

I have even tried read=all and write = all

@ettoreleandrotognoli
Copy link
Owner

Your settings looks right for me
Do you know if the login command is completing?

I'm running it:

# ...
def event_notification(source, event):
    print(event)

client = AMIClient(**connection)
future = client.login(**login)
if future.response.is_error():
    raise Exception(str(future.response))
print(future.response)

client.add_event_listener(event_notification)
# ...

And getting this:

Response: Success
ActionID: 0
Message: Authentication accepted

Event : SuccessfulAuth -> {'Privilege': 'security,all', 'EventTV': '2022-04-18T11:44:12.568+0000', 'Severity': 'Informational', 'Service': 'AMI', 'EventVersion': '1', 'AccountID': 'admin', 'SessionID': '0x7fdeec002b60', 'LocalAddress': 'IPV4/TCP/0.0.0.0/5038', 'RemoteAddress': 'IPV4/TCP/127.0.0.1/39788', 'UsingPassword': '0', 'SessionTV': '2022-04-18T11:44:12.568+0000'}

@nouman-ux
Copy link
Author

image

my output is little different from you i cant see this Event thing.

@Mmtt-DDE
Copy link

Same trouble. with previous version no problem to get the event. but now no event caugth.
I have a look on code and perform some tests, and I get the event if I suppress the line in AMICLient class, connect function
self._socket.settimeout(self._timeout)

with no timeout set (as it is in previous version), events are well caught

@mmaridev
Copy link

mmaridev commented Jan 4, 2023

Same here

mmaridev added a commit to mmaridev/python-ami that referenced this issue Jan 4, 2023
@palmtop
Copy link

palmtop commented Feb 23, 2023

You can workarround this problem by passing the timeout parameter to the initialization of client:

client = asterisk.ami.AMIClient(address='127.0.0.1',port=5038,timeout=None)

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

5 participants