Asterisk ARI Rest API make call and play a wav file

Hi,

I am a beginner in Asterisk and I am trying to operate Asterisk using REST api. I am having an Asterisk server and three SIP agents connected to it with number 9001,9002,9003.

My motive is to make call to 9002 from 9001 using REST api and and call and the play a wav file in 9002 from 9001. All these operation i want to achieve using REST api and curl.

I am able to call from my PC using the below curl command. But when we attend the call in SIP agent its disconnects, it not continuing in the call.

curl -v -u aritest:passme -X POST "http://192.168.43.212:8088/ari/channels?endpoint=SIP/9002&extension=9001&context=from-internal&priority=1&callerId=9001"

What does the Asterisk console show?

pbx.c: channel 'SIP/9003-00000004' sent to invalid extension but no invalid handler: context,exten,priority=from-internal,9001,1

There is your answer. It was sent to an invalid extension upon answer.

How to debug and find this extension number

It would be in the dialplan, extensions.conf. That is not something Asterisk produces but is configured and defined either by the deployer/administrator or a GUI.

This is the content of extensions.conf


[general]
static=yes
writeprotect=no
priorityjumping=no
autofallthrough=yes
clearglobalvars=no

[default]
exten => 9001,1,Dial(SIP/9001,10)
exten => 9002,1,Dial(SIP/9002,10)
exten => 9003,1,Dial(SIP/9003,10)
exten => 1000,1,NoOp()
 same =>      n,Answer()
 same =>      n,Stasis(channel-dump)
 same =>      n,Hangup()

You have sent the call to the “from-internal” context but everything is in “default”.

What should be the changes to be implemented?

I’ve told you what needs to be changed but haven’t fixed your curl request. This is on purpose because I’m trying to get you to do some investigation, research, and learning on your own. Contexts and dialplan are a fundamental aspect of Asterisk and you need to have the basics of them to be able to use it.

I modified the curl request to default

curl -v -u aritest:passme -X POST "http://192.168.43.212:8088/ari/channels?endpoint=SIP/9002&extension=9001&context=default&priority=1&callerId=9001"

still the call holds for 30 seconds, these are the errors i get in log


[Feb 19 18:36:11] WARNING[12671] chan_sip.c: Retransmission timeout reached on transmission 29c88cb873f066885a0935850de36444@192.168.43.212:5060 for seqno 102 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 32000ms with no response
[Feb 19 18:36:23] WARNING[12611] db.c: Error executing SQL (COMMIT): database is locked
[Feb 19 18:36:26] WARNING[12671] chan_sip.c: Retransmission timeout reached on transmission 15e95bce7f1300812f70bc5061f13327@192.168.43.212:5060 for seqno 102 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 31999ms with no response
[Feb 19 18:36:30] ERROR[12671] netsock2.c: getaddrinfo("(null)", "(null)", ...): Name or service not known
[Feb 19 18:36:30] WARNING[12671] chan_sip.c: Invalid host name in Contact: (can't resolve in DNS) : '(null)'
[Feb 19 18:36:30] ERROR[12671] netsock2.c: getaddrinfo("(null)", "(null)", ...): Name or service not known
[Feb 19 18:36:30] WARNING[12671] chan_sip.c: Can't find address for host '(null)'
[Feb 19 18:36:40] ERROR[12717][C-00000000] netsock2.c: getaddrinfo("(null)", "(null)", ...): Name or service not known
[Feb 19 18:36:40] WARNING[12717][C-00000000] chan_sip.c: Can't find address for host '(null)'
[Feb 19 18:37:02] WARNING[12671] chan_sip.c: Retransmission timeout reached on transmission 453cca0a2891d33e1f6192dd328e6b3b@192.168.43.212:5060 for seqno 102 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 31999ms with no response
[Feb 19 18:37:30] WARNING[12611] db.c: Error executing SQL (COMMIT): database is locked

It couldn’t send the SIP request to whatever you called. You’ve also got a broken local sqlite database, I don’t know what would have caused it. Your networking also seems problematic.

How to fix the local sql database? If i issue asterisk -cvvvvv and check core show channels command the Asterisk cli shows 0 active calls while an active call is going on between two SIP agents.

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