greenfieldtech-nirs / phpari

A Class Library enabling Asterisk ARI functionality for PHP
GNU Lesser General Public License v2.1
89 stars 56 forks source link

Cannot redirect or continue channel #52

Closed kunwon1 closed 7 years ago

kunwon1 commented 7 years ago

Hi there

I have an ARI application to which I attempted to add a new function using channel_continue

The channel that I am attempting to continue has been answered and had ringing started

When I continue the channel I see dialplan execution continuing in asterisk but I get no audio on the channel. The channel is able to pass audio when, instead of continuing, I start playback on the channel. This is whether or not I specify context,extension,priority, both methods of invocation have the same behavior

Do I need to add the channel to a bridge first or something? It seems like I'm missing something obvious.

Please let me know if you need additional data to help track this down, I will provide whatever is necessary, it will take some time to create a sanitized test case, but I can do that if it's necessary

91Abdullah commented 7 years ago

You need to add both channels into bridge when you want to have two-way audio communication.

  1. Create a mixing bridge
  2. Add both channels to bridge
kunwon1 commented 7 years ago

I am not attempting to have two-way audio communication between two channels, I'm attempting to have a channel continue dialplan execution, which it does, but no audio passes

This is after audio was passed on the channel during its time in the Stasis app

kunwon1 commented 7 years ago

.pcap shows a POST to /ari/channels/channelid/continue

Then we get two HTTP 204 responses in sequence

Then phpari sends a DELETE to /ari/channels/channelid

All of this happens within a millisecond or two

Is this expected behavior?

kunwon1 commented 7 years ago

I have created a test case. I may be able to minimize it more with more work, we will see. This is code built on the BasicStasisApplication class provided as an example.

When you dial in to the stasis app, another channel is originated. When it is answered, we playback a 'press 1 to accept this call' sound file and wait for DTMF. When DTMF is received we either connect the two channels or continue the first channel back into the dialplan. The first option works, the second doesn't. The original channel continues into the dialplan as is evident by asterisk logs, but there is no audio passed, and the original channel is hung up a second or two later.

attachments:

phparibug.php.txt is the test case composer.json.txt has the dependencies for the test case asterisk.log.txt is the full log from asterisk showing this test in progress dialplan.txt is the entry and exit points for the stasis app. There are extra args there but they aren't used in this minimized test case, just forgot to remove them

phparibug.php.txt composer.json.txt asterisk.log.txt dialplan.txt

kunwon1 commented 7 years ago

I've found that if I remove phpari's ability to delete channels by adding 'return false;' to the beginning of the method, this works as intended. Going to start hunting for why phpari is sending that delete.

kunwon1 commented 7 years ago

And now I feel silly- it's part of the BasicStasisApplication. When a channel is continued, it fires a StasisEnd event (which should have been obvious to me) and the BasicStasisApplication has code that 'intentionally generates an error' because it attempts to delete the channel that's already been deleted by asterisk. Except it hasn't been deleted if the channel is continued, so the stasis app deletes its own channel

Very sorry for the time i wasted through my lack of understanding, thanks for the help everyone :)

greenfieldtech-nirs commented 7 years ago

Hi There,

Actually, the time you invested is really important. This 'design consideration' of the demo application should be documented in here. I'm heading to KamailioWorld, do if I'll have some free time I'll add this.

Much appreciated.

Nir S