Good morning/evening to all, im pretty new to Asterisk and FreePBX and im a newbie in this field, and i was trying to find a solution to “redirect” an inbound SIP call to a dynamic external number via sip trunk.
The flow i want to achieve is:
Incoming SIP call
Asterisk reads destination number (from custom header)
Call continues to ring until callee responds, so that the incoming SIP call becomes an outbound call to the destination
Is this possible?
I’ve already tried doing something like this:
exten => 900,1,Set(CALLERID(num)=callerid)
same => n,Dial(PJSIP/destination@trunk_name)
same => n,Hangup()
And it kind of works, but if not answered quickly the call drops after a few seconds of ringing
That should work and there should be no time limit other than any imposed by the upstream system on the incoming side, or the downstream system on the called side.
When i dial normaly to the trunk theres no ringing timeout, my guess is that Dial tries to connect the outgoing call to the channel, but its closed because Answer() hasn’t been invoked yet. I also saw in the logs that Dial “exits non-zero”
Dial doesn’t work like that. It doesn’t care whether the A side has already been answered. “Exits non-zero” means the calling party hung up, or aborted, or the call was answered by the called party and subsequently hung up by them, and the g option was not selected.
I would want to see the “pjsip set logger on” output for both sides. I expect you will see CANCEL from the calling side.
If the PBX is behind a NAT, confirm that the external router/firewall is properly forwarding the RTP port range to the PBX (default is UDP ports 10000-20000).
In the incoming trunk, try setting Inband Progress to Yes.
In the Inbound Route, try setting Signal Ringing to Yes.
If you still have trouble, at the Asterisk command prompt type pjsip set logger on
make a failing (dropped) call, paste the Asterisk log for the call at pastebin.freepbx.org and post the link here.
If you are too new to post links, just post the last eight hex characters of the link.
I looked a the logs myself and the CANCEL does come indeed from the trunk the inbound DID is registered on, could it be an issue of RTP no activity timeout?
Ok after a little bit more of debugging, i found out that with calling the extension directly via softphone (the same the inbound DID connects to) the call doesn’t drop while ringing, so its probably a trunk issue
A couple of seconds after what? If canceled two seconds after the incoming INVITE, you would never hear ringing and the call would fail even if answered immediately.
Please provide actual timestamps for the various events so I can understand the relationship.