python-ami icon indicating copy to clipboard operation
python-ami copied to clipboard

I can't get the values

Open ilya-savichev opened this issue 3 years ago • 13 comments

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

ilya-savichev avatar Jun 08 '22 09:06 ilya-savichev

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

ettoreleandrotognoli avatar Jun 08 '22 10:06 ettoreleandrotognoli

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):

ilya-savichev avatar Jun 08 '22 12:06 ilya-savichev

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)

ettoreleandrotognoli avatar Jun 08 '22 13:06 ettoreleandrotognoli

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 avatar Jun 08 '22 13:06 ilya-savichev

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

ilya-savichev avatar Jun 08 '22 13:06 ilya-savichev

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

ettoreleandrotognoli avatar Jun 08 '22 14:06 ettoreleandrotognoli

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

ilya-savichev avatar Jun 08 '22 14:06 ilya-savichev

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?

ettoreleandrotognoli avatar Jun 08 '22 14:06 ettoreleandrotognoli

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 avatar Jun 08 '22 14:06 ilya-savichev

image

ilya-savichev avatar Jun 08 '22 14:06 ilya-savichev

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?

ilya-savichev avatar Jun 14 '22 17:06 ilya-savichev

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

nelsonyoneyama avatar May 05 '23 14:05 nelsonyoneyama

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 :-)

avonderlieth avatar Apr 26 '24 14:04 avonderlieth