I have an Asterisk server and a custom developed client for extension registration. And I would like to trigger some function on this Asterisk server by sending a SIP request.
And also I need to get back the result of the executed task to the client application.
In my situation, a direct HTTP request sending is not possible between Asterisk server and the client.
So I require a solution based on SIP itself. Is there any way to do this using SIP OPTIONS, SIP MESSAGE or by means of any other requests?
Why not use AMI to send action to Asterisk and monitor Events?
âSatish Barot
You can send Asterisk SIP MESSAGE messages and take action on them in the dialplan. On a pjsip endpoint, just set âmessage_contextâ to a dialplan context like âincoming_messagesâ or something, then you can use the MESSAGE or MESSAGE_DATA functions to read the contents. You can then do anything the dialplan allows with the data.
Thanks for the quick response. If you can, please provide more details or links about how we construct SIP MESSAGE request , where we include the data for the invocation and also how will be the response
because In our case, we must use a SIP flow for this. clinet and Asterisk server can only communicate via SIP
A SIP MESSAGE looks like any other SIP request. Hereâs an exampleâŚ
MESSAGE sip:[extn]@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: charlie <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
To: alice <sip:[extn]@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 MESSAGE
Max-Forwards: 70
Contact: <sip:[service]@[local_ip]:[local_port];transport=[transport]>
Subject: Test
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, PRACK, REGISTER, REFER, MESSAGE
User-Agent: Test
Content-Type: text/plain
Content-Length: [len]
this is a test
Substitute the variables in â[]â with your own values.
Youâll get a 202 response back.