Error when doing ARI Record

[2023-09-05 06:18:57] WARNING[18236]: ari/resource_channels.c:846 ast_ari_channels_record: Unrecognized recording error: No such file or directory
when i use ARI record i am getting this error

You would need to provide more information, such as actually showing the ARI interaction and API calls.

import ari
import requests
import json
import threading
from requests.auth import HTTPBasicAuth

def listen_to_ari_events():
client.run(apps=‘my-stasis-app’)

def on_stasis_start(channel_obj, ev):
channel = channel_obj[‘channel’]
channel_id = channel.json[‘id’]

print("Stasis Start received on channel {} with ID {}".format(channel.json['name'], channel_id))

# Trigger the POST request to start recording
record_url = "http://localhost:8088/ari/channels/{}/record".format(channel_id)
record_params = {
    'name': 'my_recording',
    'format': 'wav',
    'maxDurationSeconds': 10,
    'beep': True,
}
try:
    record_response = requests.post(record_url, params=record_params, auth=HTTPBasicAuth(username, password))
    record_response.raise_for_status()  # Raise HTTPError for bad responses (4xx and 5xx)
    print("Started recording: {}".format(record_response.json()))
except requests.RequestException as e:
    print("Failed to start recording: {}".format(e))

ARI Connection

username = ‘vitalpbx’
password = ‘zcWGYbNnPer2YUBTg433EMuVs’
client = ari.connect(‘http://localhost:8088’, username, password)

ARI Event Subscription

client.on_channel_event(‘StasisStart’, on_stasis_start)

Start listening for ARI events in a new thread

ari_thread = threading.Thread(target=listen_to_ari_events)
ari_thread.start()

i have ARI debug on and it gives 500 internal server error
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [1002@cos-all:1] NoOp(“SIP/1008-0000001c”, “start”) in new stack
– Executing [1002@cos-all:2] Answer(“SIP/1008-0000001c”, “”) in new stack
– Executing [1002@cos-all:3] Stasis(“SIP/1008-0000001c”, “my-stasis-app,1008”) in new stack
<— Sending ARI event to 127.0.0.1:55788 —>
{“type”:“StasisStart”,“timestamp”:“2023-09-05T09:05:53.237+0000”,“args”:[“1008”],“channel”:{“id”:“1693904752.56”,“name”:“SIP/1008-0000001c”,“state”:“Up”,“caller”:{“name”:“1008”,“number”:“1008”},“connected”:{“name”:“”,“number”:“”},“accountcode”:“”,“dialplan”:{“context”:“cos-all”,“exten”:“1002”,“priority”:3,“app_name”:“Stasis”,“app_data”:“my-stasis-app,1008”},“creationtime”:“2023-09-05T09:05:52.732+0000”,“language”:“en”},“asterisk_id”:“9e:23:57:1d:d2:da”,“application”:“my-stasis-app”}
<— ARI request received from: 127.0.0.1:55796 —>
Host: localhost:8088
Content-Length: 0
Accept-Encoding: gzip, deflate
Accept: /
User-Agent: python-requests/2.6.0 CPython/2.7.5 Linux/3.10.0-1127.19.1.el7.x86_64
Connection: keep-alive
Authorization: Basic dml0YWxwYng6emNXR1liTm5QZXIyWVVCVGc0MzNFTXVWcw==
beep: True
format: wav
name: my_recording
maxDurationSeconds: 10
body:

[2023-09-05 09:05:53] WARNING[31679]: ari/resource_channels.c:846 ast_ari_channels_record: Unrecognized recording error: No such file or directory
<— Sending ARI response to 127.0.0.1:55796 —>
500 Internal Server Error
Content-type: application/json
{“message”:“Internal Server Error”}

<— Sending ARI event to 127.0.0.1:55788 —>
{“variable”:“RTPAUDIOQOS”,“value”:“ssrc=295723994;themssrc=0;lp=0;rxjitter=0.000000;rxcount=0;txjitter=0.000000;txcount=0;rlp=0;rtt=0.000000”,“type”:“ChannelVarset”,“timestamp”:“2023-09-05T09:05:55.553+0000”,“channel”:{“id”:“1693904752.56”,“name”:“SIP/1008-0000001c”,“state”:“Up”,“caller”:{“name”:“1008”,“number”:“1008”},“connected”:{“name”:“”,“number”:“”},“accountcode”:“”,“dialplan”:{“context”:“cos-all”,“exten”:“1002”,“priority”:3,“app_name”:“Stasis”,“app_data”:“my-stasis-app,1008”},“creationtime”:“2023-09-05T09:05:52.732+0000”,“language”:“en”},“asterisk_id”:“9e:23:57:1d:d2:da”,“application”:“my-stasis-app”}
<— Sending ARI event to 127.0.0.1:55788 —>
{“variable”:“RTPAUDIOQOSJITTER”,“value”:“minrxjitter=0.000000;maxrxjitter=0.000000;avgrxjitter=0.000000;stdevrxjitter=0.000000;reported_minjitter=0.000000;reported_maxjitter=0.000000;reported_avgjitter=0.000000;reported_stdevjitter=0.000000;”,“type”:“ChannelVarset”,“timestamp”:“2023-09-05T09:05:55.553+0000”,“channel”:{“id”:“1693904752.56”,“name”:“SIP/1008-0000001c”,“state”:“Up”,“caller”:{“name”:“1008”,“number”:“1008”},“connected”:{“name”:“”,“number”:“”},“accountcode”:“”,“dialplan”:{“context”:“cos-all”,“exten”:“1002”,“priority”:3,“app_name”:“Stasis”,“app_data”:“my-stasis-app,1008”},“creationtime”:“2023-09-05T09:05:52.732+0000”,“language”:“en”},“asterisk_id”:“9e:23:57:1d:d2:da”,“application”:“my-stasis-app”}
<— Sending ARI event to 127.0.0.1:55788 —>
{“variable”:“RTPAUDIOQOSLOSS”,“value”:“minrxlost=0.000000;maxrxlost=0.000000;avgrxlost=0.000000;stdevrxlost=0.000000;reported_minlost=0.000000;reported_maxlost=0.000000;reported_avglost=0.000000;reported_stdevlost=0.000000;”,“type”:“ChannelVarset”,“timestamp”:“2023-09-05T09:05:55.553+0000”,“channel”:{“id”:“1693904752.56”,“name”:“SIP/1008-0000001c”,“state”:“Up”,“caller”:{“name”:“1008”,“number”:“1008”},“connected”:{“name”:“”,“number”:“”},“accountcode”:“”,“dialplan”:{“context”:“cos-all”,“exten”:“1002”,“priority”:3,“app_name”:“Stasis”,“app_data”:“my-stasis-app,1008”},“creationtime”:“2023-09-05T09:05:52.732+0000”,“language”:“en”},“asterisk_id”:“9e:23:57:1d:d2:da”,“application”:“my-stasis-app”}
<— Sending ARI event to 127.0.0.1:55788 —>
{“variable”:“RTPAUDIOQOSRTT”,“value”:“minrtt=0.000000;maxrtt=0.000000;avgrtt=0.000000;stdevrtt=0.000000;”,“type”:“ChannelVarset”,“timestamp”:“2023-09-05T09:05:55.554+0000”,“channel”:{“id”:“1693904752.56”,“name”:“SIP/1008-0000001c”,“state”:“Up”,“caller”:{“name”:“1008”,“number”:“1008”},“connected”:{“name”:“”,“number”:“”},“accountcode”:“”,“dialplan”:{“context”:“cos-all”,“exten”:“1002”,“priority”:3,“app_name”:“Stasis”,“app_data”:“my-stasis-app,1008”},“creationtime”:“2023-09-05T09:05:52.732+0000”,“language”:“en”},“asterisk_id”:“9e:23:57:1d:d2:da”,“application”:“my-stasis-app”}
<— Sending ARI event to 127.0.0.1:55788 —>
{“type”:“ChannelHangupRequest”,“timestamp”:“2023-09-05T09:05:55.554+0000”,“channel”:{“id”:“1693904752.56”,“name”:“SIP/1008-0000001c”,“state”:“Up”,“caller”:{“name”:“1008”,“number”:“1008”},“connected”:{“name”:“”,“number”:“”},“accountcode”:“”,“dialplan”:{“context”:“cos-all”,“exten”:“1002”,“priority”:3,“app_name”:“Stasis”,“app_data”:“my-stasis-app,1008”},“creationtime”:“2023-09-05T09:05:52.732+0000”,“language”:“en”},“asterisk_id”:“9e:23:57:1d:d2:da”,“application”:“my-stasis-app”}
– Executing [h@cos-all:1] Hangup(“SIP/1008-0000001c”, “”) in new stack
== Spawn extension (cos-all, h, 1) exited non-zero on ‘SIP/1008-0000001c’
<— Sending ARI event to 127.0.0.1:55788 —>
{“type”:“StasisEnd”,“timestamp”:“2023-09-05T09:05:55.554+0000”,“channel”:{“id”:“1693904752.56”,“name”:“SIP/1008-0000001c”,“state”:“Up”,“caller”:{“name”:“1008”,“number”:“1008”},“connected”:{“name”:“”,“number”:“”},“accountcode”:“”,“dialplan”:{“context”:“cos-all”,“exten”:“1002”,“priority”:3,“app_name”:“Stasis”,“app_data”:“my-stasis-app,1008”},“creationtime”:“2023-09-05T09:05:52.732+0000”,“language”:“en”},“asterisk_id”:“9e:23:57:1d:d2:da”,“application”:“my-stasis-app”}
> Blockquotestrong text

i have tried adding the path monitor directory, and I have tried using the requests library to do a put request instead of using ari library. I thought maybe there was some issue in the library.
My asterisk version is 18.12.1
I have checked it on Google as well as chatGPT but couldn’t find any solution. I have checked the directory/files permission as well

any update ?

This is not a support ticketing system with an SLA. People respond if and when they desire. I have nothing personally else to add to this thread at this time.

OK is there any other platform where I can ask for help ?
thank you for your response

If you need urgent help, you could use for a consultant, specializing in Asterisk, theres also a jobs category you can go to, to find someone you can hire to help you do the job.

That being said, I think you are doing something wrong in regards to filename. You need to make sure the path exists, and is writable by Asterisk. You might even need to supply a FULL path for the file, not just the filename.

And in the future you might want to remove your basic auth header, as it’s just a base64 encoded version of your username and password, with a : inbetween. So if the password you’re using in the sample request is something you use elsewhere, consider it compromised, and handle it accordingly.

I have tried giving the full path and I tried the mix monitor application and record application from the dial plan, Asterisk is able to store audio in the same directory so I don’t think it’s a directory issue. I am planning to deploy only asterisk instead of vitalpbx then will try to setup everything there

so I installed the asterisk on a new server and did everything from the start. this time record is working. so looks like it was may be some permission or installation issue

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.