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

panoramisk not capturing result of Async AGI command #107

Closed
gedia opened this issue May 31, 2022 · 2 comments
Closed

panoramisk not capturing result of Async AGI command #107

gedia opened this issue May 31, 2022 · 2 comments

Comments

@gedia
Copy link

gedia commented May 31, 2022

Hello,

I've been experimenting with panoramisk lately, and I've discovered what I believe to be a bug, and also a potential solution for it. However, I'm opening an issue rather than a pull request since I'm by no means an expert in either panoramisk or asyncio.

The following statements:

action = actions.Command({'Action': 'AGI',
                          'Channel': agi['agi_channel'],
                          'Command': 'GET FULL VARIABLE ${PJSIP_HEADER(read,Call-ID)}'},
                          as_list=True)
res = await manager.send_action(action)

do not yield a result with code from the current git master. After digging a little, I found that in def completed(self) in actions.py, none of the conditions match the AsyncAGIExec event asterisk produces, and which carries the result. A patch as simple as:

--- a/panoramisk/actions.py
+++ b/panoramisk/actions.py
@@ -90,6 +90,8 @@
         resp = self.responses[-1]
         if resp.event.endswith('Complete'):
             return True
+        elif resp.event in ('AsyncAGIExec'):
+            return True
         elif resp.subevent in ('End', 'Exec'):
             return True
         elif resp.response in ('Success', 'Error', 'Fail', 'Failure'):

seems to fix that, but I'm not sure if that's the best approach here.

Here's the sequence of actions/events the send_action above triggers:

<--- Examining AMI action: -->
Action: AGI
ActionID: action/186daec3-bfdc-437d-b110-1fb7cfc019d8/1/1196
Channel: PJSIP/test-gd-0000003d
Command: GET FULL VARIABLE ${PJSIP_HEADER(read,Call-ID)}
CommandID: command/1ac20057-d646-431e-87aa-976b15caa68a/1/3

<-- Examining AMI event: -->
Event: AGIExecStart
Privilege: agi,all
SequenceNumber: 964
File: manager.c
Line: 1864
Func: manager_default_msg_cb
SystemName: mgw0-stage-tis0-cn1
Channel: PJSIP/test-gd-0000003d
ChannelState: 4
ChannelStateDesc: Ring
CallerIDNum: test-gd
CallerIDName: stage
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: gr
AccountCode: 165
Context: endpoints-in
Exten: 123456
Priority: 1
Uniqueid: mgw0-stage-tis0-cn1-1653995979.61
Linkedid: mgw0-stage-tis0-cn1-1653995979.61
CommandId: 1082775508
Command: GET FULL VARIABLE ${PJSIP_HEADER(read,Call-ID)}


<-- Examining AMI event: -->
Event: AGIExecEnd
Privilege: agi,all
SequenceNumber: 965
File: manager.c
Line: 1864
Func: manager_default_msg_cb
SystemName: mgw0-stage-tis0-cn1
Channel: PJSIP/test-gd-0000003d
ChannelState: 4
ChannelStateDesc: Ring
CallerIDNum: test-gd
CallerIDName: stage
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: gr
AccountCode: 165
Context: endpoints-in
Exten: 123456
Priority: 1
Uniqueid: mgw0-stage-tis0-cn1-1653995979.61
Linkedid: mgw0-stage-tis0-cn1-1653995979.61
CommandId: 1082775508
Command: GET FULL VARIABLE ${PJSIP_HEADER(read,Call-ID)}
ResultCode: 200
Result: Success


<-- Examining AMI event: -->
Event: AsyncAGIExec
Privilege: agi,all
SequenceNumber: 966
File: manager.c
Line: 1864
Func: manager_default_msg_cb
SystemName: mgw0-stage-tis0-cn1
Channel: PJSIP/test-gd-0000003d
ChannelState: 4
ChannelStateDesc: Ring
CallerIDNum: test-gd
CallerIDName: stage
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: gr
AccountCode: 165
Context: endpoints-in
Exten: 123456
Priority: 1
Uniqueid: mgw0-stage-tis0-cn1-1653995979.61
Linkedid: mgw0-stage-tis0-cn1-1653995979.61
Result: 200%20result%3D1%20(586f113295b1f8b6dd9dc39bcedfdc80)%0A
CommandId: command/1ac20057-d646-431e-87aa-976b15caa68a/1/3

After the patch, the future contains two items in a list, the first holding the Message='Added AGI command to queue' and Response='Success' keys (this event doesn't show up in asterisk manager debug, wonder why), the second the contents of AsyncAGIExec event above, including the Result key which carries the information needed.

@kontsaki
Copy link

#89

@gedia
Copy link
Author

gedia commented May 19, 2023

I believe this is fixed in 3d851ce so since I'm the author of this issue I'm gonna go ahead and close it. Thanks!

@gedia gedia closed this as completed May 19, 2023
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

2 participants