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

I can't get the values #51

Open
ilya-savichev opened this issue Jun 8, 2022 · 13 comments
Open

I can't get the values #51

ilya-savichev opened this issue Jun 8, 2022 · 13 comments

Comments

@ilya-savichev
Copy link

ilya-savichev commented Jun 8, 2022

hi, in the telenet I successfully get the queue state, the same thing in python comes empty. what's wrong?
image
client = AMIClient(address='чччччч',port=5038) client.login(username='python',secret='5bdadc4820df193691d5848b8cb566de') action = SimpleAction( 'QueueStatus',) resp1=client.send_action(action) response3 = resp1.response print(response3)

image
image

@ettoreleandrotognoli
Copy link
Owner

The events don't go to the response, you need to add a listener to collect them

This is the response:

Response: Success
...

This

Event: QueueParams
...

and this:

Event: QueueMember
...

are events

@ilya-savichev
Copy link
Author

The events don't go to the response, you need to add a listener to collect them

This is the response:

Response: Success
...

This

Event: QueueParams
...

and this:

Event: QueueMember
...

are events

image
Thank you, I didn't understand how to do it? response
this is the 'asterisk.ami.response' type.Response'> . Do I need to iterate somehow? then how? or send response 3 to
def event_listener(event,**kwargs):

@ettoreleandrotognoli
Copy link
Owner

try something like that:

def event_listener(event):
  print(event)

# add the event listener before send the action  
client.add_event_listener(event_listener)

future = client.send_action(action)
print(future.response)

@ilya-savichev
Copy link
Author

Work!
but after a minute of work, freepbx (DOWN) freezes, . although I filter events.
how can I get a QueueStatus response?, because here I get queue joining events, and I need queue agents registered at this moment
image

@ilya-savichev
Copy link
Author

try something like that:

def event_listener(event):
  print(event)

# add the event listener before send the action  
client.add_event_listener(event_listener)

future = client.send_action(action)
print(future.response)

image

@ettoreleandrotognoli
Copy link
Owner

But this time you sent the action twice, in the lines 27 and 34
Try to add the listener before the line 27

@ilya-savichev
Copy link
Author

But this time you sent the action twice, in the lines 27 and 34 Try to add the listener before the line 27

I added 2 times to show that the response is returned and the event is not
image

@ettoreleandrotognoli
Copy link
Owner

The response returns before the events, so it really can happen, maybe your process was closed before receiving the events
In your example that worked you did a while to keep the process running, that makes some sense, but I don't know why your response is None

I have one concern with your while, in the way that you did I imagine that it is consuming a lot of CPU time, I would try to use a sleep inside the while

Is there any event that ends the event stream?

@ilya-savichev
Copy link
Author

image
I already tried to connect to another PBX, the result is the same. in the example where everything is read from the ATs port, for some reason it freezes after a minute and hangs after stopping the python (((((maybe my version of asterisk.ami is old?

@ilya-savichev
Copy link
Author

image

@ilya-savichev
Copy link
Author

The response returns before the events, so it really can happen, maybe your process was closed before receiving the events In your example that worked you did a while to keep the process running, that makes some sense, but I don't know why your response is None

I have one concern with your while, in the way that you did I imagine that it is consuming a lot of CPU time, I would try to use a sleep inside the while

Is there any event that ends the event stream?

image

Hello, I started sending data after adding a callback))). tell me how to get out of the endless loop try?

@nelsonyoneyama
Copy link

try putting the parameter timeout=None in the client.login line like this:
client = AMIClient(address='127.0.0.1',port=5038,timeout=None)

@avonderlieth
Copy link

try putting the parameter timeout=None in the client.login line like this: client = AMIClient(address='127.0.0.1',port=5038,timeout=None)

Thanks SOOOOOOO much - this was driving me nuts, and such a simple solution :-)

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

4 participants