Unable to change Contact header value in ARI outbound call

Hi Team,

Hope you are having amazing time. I am using Asterisk ARI with Java statis application to build my IVR/OBD solution. I am trying to make outbound call using Channel with ID ARI API with following request body:

{
“app”: “statis_app_name”,
“endpoint”: “PJSIP/devtest/sip:CALLEE_NUMBER@CALLEE_SIP_IP:5060”,
“callerId”: “CALLER_NAME <CALLER_NUMBER>”
}

The issue is that I am always getting following contact header in INVITE packet:
sip:asterisk@CALLER_IP:PORT

Is there any way to change it dynamically using ARI only? I am using PJSIP driver and following is the pjsip.conf endpoint configuration:

[devtest]
type=endpoint
disallow=all
allow=alaw,ulaw
media_address=RTP_IP
bind_rtp_to_media_address=yes
rewrite_contact=yes
;contact_user=custom_contact_user

when I use contact_user, contact header is changed to hardcoded value but I want dynamic contact header in below format
sip:CALLER_NUMBER@CALLER_IP:PORT

I tried sending sip_headers in JSON request body, tried sending variable also in JSON but didn’t get any success. Can anyone suggest if it is possible to change dynamically using Statis application only? By the way, I’m using Asterisk version 18.8.0 on CentOS

Thanks

The only ability to set it dynamically ANYWHERE is by enabling the use_callerid_contact option[1] in global, and using callerid.

[1] https://docs.asterisk.org/Asterisk_20_Documentation/API_Documentation/Module_Configuration/res_pjsip/#use_callerid_contact

If you need to do this, the other endpoint is broken.

Thank you @jcolp. It’s working as expected.

I’m testing this change for all my use cases and seems it’s fine for my use cases to implement this change. Will ask again if I face any issue.

Thanks for your support.

I’m facing one more issue. For outbound calls made via ARI (using Channel with ID), asterisk is not sending ACK for 200 OK (INVITE) message. Could you please guide me how this issue can be fixed. Contact header one is working like a charm, just this issue is remaining.

Due to this, call is not getting terminated properly on statis application end. Do I need to enable/disable something in pjsip.conf to make it work or other information is required for my end? Asterisk configuration is similar to above one.

Thanks in advance for your support…

There is no configuration specifically for ACK. It is commonly a result of networking configuration, NAT, firewall, or SIP ALG. You would need to actually show a SIP trace (pjsip set logger on), including if Asterisk is receiving the 200 OK.

1 Like

Yes, asterisk is receiving 200 OK (INVITE) from other end but it is not sending ack for the same. Due to confidential data, I won’t be able to share SIP trace

Hi, there is one more issue. I enabled p-asserted-header to sent in outbound call but it is being sent in different format than expected one. following is the request body which I am sending to originate with id ARI endpoint.

final Map<String, Object> body = new HashMap<>();
body.put(“callerId”, getCallerId(callerName, callerNumber));
body.put(“endpoint”, dialoutAddress);
body.put(“app”, obdAppName);

    final Map<String, Object> channelVars = new HashMap<>();
    channelVars.put("P-Asserted-Identity", "<tel:" + callerNumber + ">");
    body.put("variables", channelVars);

Currently, I’m getting following PAI header:
“caller_number” <sip:caller_number@caller_sip_ip>

Could you please guide on this issue.

Resolved. send_pai=yes in pjsip.conf was overwriting the header sent to originate ARI api.