Unable to set outgoing callerID in a Stasis originated channel unless the REST POST includes a caller ID

Welcome to my lovely corner. I think I’ve found a case.

I’m originating calls from a Stasis app and I want to route some of them out the PSTN. In my dialplan I set my outgoing callerID like so:

exten => 1250,1,Set(CALLERID(all)="[Outgoing CID]" <+[OUTGOING NUMBER]>)
exten => 1250,n,Dial(PJSIP/+[CALLED NUMBER]@Twilio,30)
exten => 1250,n,Hangup()

This works fine if I call it from a phone:

    -- Executing [1250@dialin_bridge_internal_dialout:1] Set("PJSIP/1215-00000010", "CALLERID(all)="[Outgoing CID]" <+[OUTGOING NUMBER]>") in new stack
    -- Executing [1250@dialin_bridge_internal_dialout:2] NoOp("PJSIP/1215-00000010", ""CallerID: "[Outgoing CID]" <+[OUTGOING NUMBER]>"") in new stack
    -- Executing [1250@dialin_bridge_internal_dialout:3] Dial("PJSIP/1215-00000010", "PJSIP/+[CALLED NUMBER]@Twilio,30") in new stack
    -- Called PJSIP/+[CALLED NUMBER]@Twilio
<--- Transmitting SIP request (956 bytes) to UDP:[IP]:5060 --->
INVITE sip:+[CALLED NUMBER]@[SIP DOMAIN] SIP/2.0
Via: SIP/2.0/UDP [IP]:5060;rport;branch=z9hG4bKPjc3729174-c995-4b2c-80e6-bc582ea97fed
From: "[Outgoing CID]" <sip:+[OUTGOING NUMBER]@[IP]>;tag=add26045-34e1-4cda-926c-82f85443b3c1
To: <sip:+[CALLED NUMBER]@[SIP DOMAIN]>

However, if I originate into this from a Stasis app in a call originated from Stasis over IAX, the Set(CALLERID(all) doesn’t work and I pass From: "Anonymous" <sip:anonymous@anonymous.invalid> to my provider:

[Create the call]
http://dialin_bridge_asterisk:8088/ari/channels?app=dialin_bridge_callout_handler&channelId=1708482891.6.dialin_bridge_callout.501276fe04cd33bcfb8913fcb25109d9&endpoint=IAX2/primary_internal/1250@dialin_bridge_internal_dialout&timeout=30

    -- Executing [1250@dialin_bridge_internal_dialout:1] Set("IAX2/dialin_bridge_internal-6534", "CALLERID(all)="[Outgoing CID]" <+[OUTGOING NUMBER]>") in new stack
    -- Executing [1250@dialin_bridge_internal_dialout:2] NoOp("IAX2/dialin_bridge_internal-6534", ""CallerID: "[Outgoing CID]" <+[OUTGOING NUMBER]>"") in new stack
    -- Executing [1250@dialin_bridge_internal_dialout:3] Dial("IAX2/dialin_bridge_internal-6534", "PJSIP/+[CALLED NUMBER]@Twilio,30") in new stack
    -- Called PJSIP/+[CALLED NUMBER]@Twilio
<--- Transmitting SIP request (952 bytes) to UDP:[IP]:5060 --->
INVITE sip:+[CALLED NUMBER]@[SIP DOMAIN] SIP/2.0
Via: SIP/2.0/UDP [IP]:5060;rport;branch=z9hG4bKPj355151a0-2e24-40bc-9360-093800f85449
From: "Anonymous" <sip:anonymous@anonymous.invalid>;tag=42268065-ff45-4a07-b25c-4c77f0939526
To: <sip:+[CALLED NUMBER]@[SIP DOMAIN]>
Contact: <sip:asterisk@[IP]:5060>

But, if I set callerId in the originate POST, then it works:

 http://dialin_bridge_asterisk:8088/ari/channels?app=dialin_bridge_callout_handler&callerId=[Outgoing CallerID]&channelId=1708483538.13.dialin_bridge_callout.b69245b514d8457f617216054d008141&endpoint=IAX2/primary_internal/1250@dialin_bridge_internal_dialout&timeout=30

    -- Executing [1250@dialin_bridge_internal_dialout:1] Set("IAX2/dialin_bridge_internal-4612", "CALLERID(all)="[Outgoing CID]" <+[OUTGOING NUMBER]>") in new stack
    -- Executing [1250@dialin_bridge_internal_dialout:2] NoOp("IAX2/dialin_bridge_internal-4612", ""CallerID: "[Outgoing CID]" <+[OUTGOING NUMBER]>"") in new stack
    -- Executing [1250@dialin_bridge_internal_dialout:3] Dial("IAX2/dialin_bridge_internal-4612", "PJSIP/+[CALLED NUMBER]@Twilio,30") in new stack
    -- Called PJSIP/+[CALLED NUMBER]@Twilio
<--- Transmitting SIP request (956 bytes) to UDP:[IP]:5060 --->
INVITE sip:+[CALLED NUMBER]@[SIP DOMAIN] SIP/2.0
Via: SIP/2.0/UDP [IP]:5060;rport;branch=z9hG4bKPjb8176f42-1d64-4927-a2b5-00866c54220a
From: "[Outgoing CID]" <sip:+[OUTGOING NUMBER]@[IP]>;tag=cb4ee206-0ee2-4ece-9591-1fc7493a94a1
To: <sip:+[CALLED NUMBER]@[SIP DOMAIN]>
Contact: <sip:asterisk@[IP]:5060>

So setting the CallerID in the /channels POST is the right thing to do, and resolved another bug I had, but why didn’t the Set(CallerID) work?

Is the IAX channel getting optimized out, and in the process, leaving some of its guts behind ? It does bridging slightly differently. There is a TODO in chan_iax2.c:

 * \todo XXX The IAX2 channel driver needs its native bridge
 * code converted to the new bridge technology scheme.

What does your iax.conf look like ?

The IAX trunk goes to another Asterisk instance that then uses SIP to connect to the PSTN. It’s the same config as in IAX2: Transfering a call back to originating server this is the stasis app in the enclave. The IAX config is dead simple, just this:

[general]
bandwidth=high
disallow=lpc10
jitterbuffer=no
encryption=yes
autokill=yes

[otherserver]
<The usual host and auth bits>
qualify=yes
trunk=yes

The SIP config is more complex, I can post it here if needed but it’s largely documented in this thread: ASTERISK and TWILIO - #16 by TJNII Note that this happened before I set up the encryption and I haven’t reproduced since.

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