ARI PLAYBACK DELETE does not work on Asterisk 14.5 or 15-beta1

Hi everybody,

I have been working on a system through ARI through C++. I have been able to execute almost all kind of command, such as play, get digits, mute, unmute, create a bridge, insert a created channel on this bridge, for example. But there is an important feature my system has to have that is not working. When a user is listening to and audio and press some digit, the audio has to stop. This way the system can process the digit the user entered and play the next audio. I implemented the suggested command for stop a playback ( https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Playbacks+REST+API#Asterisk14PlaybacksRESTAPI-stop ), I mean, the DELETE for /playbacks/{playbackId}.
I am able to play an audio and get a playbackId ( since I provided one I choosed at the command I sent ).

For example, I send a play command and try to stop this play. But this doen’t work.

PLAY COMMAND - "/ari/channels/{CHANNEL ID}/play/{PLAY BACK ID}?media=sound:{SOUND FILE NAME}&lang={LANGUAGE}"
Bellow is the REST reosponde sent by ASTERISK

PLAY STATUS : 201
PLAY BODY : {{
“message”: “Invalid event source URI scheme”
}{
“id”: “1”,
“media_uri”: “sound:VerificaIdade_BemVindo”,
“target_uri”: “channel:1504531606.16”,
“language”: “App/Prompts/VerificaIdade”,
“state”: “queued”
}}
This command works fine, since I inserted my sound (*.alaw ) inside the directory ( /var/lib/asterisk/sounds). From this path I created the one that appears in language : /App/Prompts . So, the complete path is /var/lib/asterisk/sounds/App/Prompts. The sound file VerificaIdade.alaw is in this directory.

To stop the ongoing play, I tryed the command
"/ari/channels/{CHANNEL ID }/playbacks/{PLAY BACK ID }"

Bellow is the REST response sent by ASTERISK
STOP PLAY STATUS : 404
STOP PLAY BODY : {{
“message”: “Invalid event source URI scheme”
}{
“id”: “1”,
“media_uri”: “sound:VerificaIdade_BemVindo”,
“target_uri”: “channel:1504531606.16”,
“language”: “App/Prompts/VerificaIdade”,
“state”: “queued”
}{
“message”: “Resource not found”
}}

The same file ASTERISK audio file found and played successfully cannot by stopped through the DELETE playback command.
Someone could implement the stop playback command successfully through ARI - REST command ?
I would appreciate some feedbacks.

That’s not the correct path. You can see the correct path in the documentation on the wiki[1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Playbacks+REST+API#Asterisk14PlaybacksRESTAPI-stop

Hi Jcolp,

Thanks for answering. The play path I am sending is playing correctly the audio file. This way I presume the path is correct for the play command.
The stop playback command doen’t even request a path. I just request a playbackId, as I provided.
Just being more specific:
Play command : “”/ari/channels/{CHANNEL ID}/play/{PLAYBACK ID}?media=sound:{SOUND FILE}&lang={LANGUAGE DIR}"
Stop playback command : “/ari/channels/{CHANNEL ID}/playbacks/{PLAYBACK ID}”

Which part of these commands you are saying isn’t correct ?

The stop playback command is incorrect. You need to do a DELETE like is documented at the link I provided.

Yes , I am sending this command, acording the specification.
If I try http DELETE and send “/playbacks/{PLAYBACK ID}” I get the response
{
“id”: “1”,
“media_uri”: “sound:VerificaIdade_BemVindo”,
“target_uri”: “channel:1504535176.26”,
“language”: “App/Prompts/VerificaIdade”,
“state”: “queued”
}
[html]
[head]
[title] 404 Not Found[/title]
[/head][body]
[h1]Not Found[/h1]
[p]The requested URL was not found on this server.[/p]
[hr /]
[address]Asterisk[/address]
[/ body][/ html]
}

If I try http DELETE through “/channels/{CHANNEL ID}/playbacks/{ PLAYBACK ID }” I get the response
"id": “1”,
“media_uri”: “sound:VerificaIdade_BemVindo”,
“target_uri”: “channel:1504535407.28”,
“language”: “App/Prompts/VerificaIdade”,
“state”: “queued”
}
[html]
[title] 404 Not Found[/title]
[/head][body]
[h1]Not Found[/h1]
[p]The requested URL was not found on this server.[/p]
[hr /]
[address]Asterisk[/address]
[/ body][/ html]
}

But, if I try http DELETE through “/ari/channels/{CHANNEL ID}/playbacks/{ PLAYBACK ID}” I get
{
“id”: “1”,
“media_uri”: “sound:VerificaIdade_BemVindo”,
“target_uri”: “channel:1504535671.30”,
“language”: “App/Prompts/VerificaIdade”,
“state”: “queued”
}{
“message”: “Resource not found”
}}

Are you absolutely sure you are doing a DELETE? The response is behaving as if you are doing a GET.

I also thought that the API could be sending not a DELETE method. So I filtered the HTTP packets via tcpdump and parsed them via Wireshark. As we can see bellow, the method HTTP used is really DELETE, but the playback is not stopping play.

Frame 26: 304 bytes on wire (2432 bits), 304 bytes captured (2432 bits)
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 45280, Dst Port: 8088, Seq: 1, Ack: 1, Len: 238
Hypertext Transfer Protocol
POST /ari/channels/1504551337.96/play/1?media=sound:VerificaIdade_BemVindo&lang=LinuxARIApp/Prompts/VerificaIdade HTTP/1.1\r\n
[Expert Info (Chat/Sequence): POST /ari/channels/1504551337.96/play/1?media=sound:VerificaIdade_BemVindo&lang=LinuxARIApp/Prompts/VerificaIdade HTTP/1.1\r\n]
Request Method: POST
Request URI: /ari/channels/1504551337.96/play/1?media=sound:VerificaIdade_BemVindo&lang=LinuxARIApp/Prompts/VerificaIdade
Request Version: HTTP/1.1
Host: localhost:8088\r\n
Authorization: Basic YXN0ZXJpc2s6YXN0ZXJpc2s=\r\n
User-Agent: aricpp\r\n
Content-Length: 0\r\n
\r\n
[Full request URI: http://localhost:8088/ari/channels/1504551337.96/play/1?media=sound:VerificaIdade_BemVindo&lang=LinuxARIApp/Prompts/VerificaIdade]
[HTTP request 1/1]
[Response in frame: 28]

F r a me 28: 440 bytes on wire (3520 bits), 440 bytes captured (3520 bits)
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 8088, Dst Port: 45280, Seq: 1, Ack: 239, Len: 374
Hypertext Transfer Protocol
HTTP/1.1 201 Created\r\n
[Expert Info (Chat/Sequence): HTTP/1.1 201 Created\r\n]
Request Version: HTTP/1.1
Status Code: 201
Response Phrase: Created
Server: Asterisk\r\n
Date: Mon, 04 Sep 2017 18:55:38 GMT\r\n
Cache-Control: no-cache, no-store\r\n
Location: /ari/playbacks/1\r\n
Content-type: application/json\r\n
Content-Length: 179\r\n
\r\n
[HTTP response 1/1]
[Time since request: 0.000321000 seconds]
[Request in frame: 26]
File Data: 179 bytes
JavaScript Object Notation: application/json

Frame 40: 214 bytes on wire (1712 bits), 214 bytes captured (1712 bits)
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 45282, Dst Port: 8088, Seq: 1, Ack: 1, Len: 148
Hypertext Transfer Protocol
DELETE /ari/channels/1504551337.96/playbacks/1 HTTP/1.1\r\n
[Expert Info (Chat/Sequence): DELETE /ari/channels/1504551337.96/playbacks/1 HTTP/1.1\r\n]
Request Method: DELETE
Request URI: /ari/channels/1504551337.96/playbacks/1
Request Version: HTTP/1.1
Host: localhost:8088\r\n
Authorization: Basic YXN0ZXJpc2s6YXN0ZXJpc2s=\r\n
User-Agent: aricpp\r\n
\r\n
[Full request URI: http://localhost:8088/ari/channels/1504551337.96/playbacks/1]
[HTTP request 1/2]
[Response in frame: 42]
[Next request in frame: 44 ]

Frame 42: 271 bytes on wire (2168 bits), 271 bytes captured (2168 bits)
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00)
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
Transmission Control Protocol, Src Port: 8088, Dst Port: 45282, Seq: 1, Ack: 149, Len: 205
Hypertext Transfer Protocol
HTTP/1.1 404 Not Found\r\n
[Expert Info (Chat/Sequence): HTTP/1.1 404 Not Found\r\n]
Request Version: HTTP/1.1
Status Code: 404
Response Phrase: Not Found
Server: Asterisk\r\n
Date: Mon, 04 Sep 2017 18:55:39 GMT\r\n
Cache-Control: no-cache, no-store\r\n
Content-type: application/json\r\n
Content-Length: 37\r\n
\r\n
[HTTP response 1/2]
[Time since request: 0.000274000 seconds]
[Request in frame: 40]
[Next request in frame: 44]
[Next response in frame: 45]
File Data: 37 bytes
JavaScript Object Notation: application/json

You need to stop trying to DELETE using that path, it won’t work no matter what. Use the path as documented and provide the result then. Others are using this without any problems, so it is most likely your usage.

Jcolp,

First you suggest to use “correcty” to PATH according documentation. That was what I did. After that you really gave a good tip about the HTTP method used ( could not be DELETE ). I used wireshark and proved the method was DELETE.
I am using what documentation suggests to do. As you claim that the playback stop works fine, I am going to try another framework to test it ( like python, for example ).
Anyway, your last answer didn’t help anything. If you don’t have any other useful tip, I appreciate your help, but I will wait for some other comment of another forum user.

I purposely didn’t provide the precise thing because I wanted you to look and investigate yourself. Here’s the precise details:

You are using “/ari/channels/1504551337.96/playbacks/1” as the path. According to the documentation it should be “/playbacks/1”.

Jcolp,

Yes, you almost was right. I mean, the problem was due to the way I was calling methods at my code.
Since I sent play command with “/ari/channels/1504551337.96/play/1?..” , for delete to work I had to send “/ari/playbacks/{PLAYBACK ID}”.
The problem was that I wasn’t sending the “ari” at the beginning of the command.
Now, inserting “ari” in the DELETE command everything worked fine.
Thanks for your help.