Redirect inbound call


(Italy) #1

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:

  1. Incoming SIP call
  2. Asterisk reads destination number (from custom header)
  3. 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


(David55) #2

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.


(Italy) #3

There are no time limits, the code works fine when i put Answer() as priority 1, but thats not the result i want


(David55) #4

If Answer makes it work, I would suggest that the upstream system is timing out the call.


(Italy) #5

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”


(David55) #6

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.


#7

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.


(Italy) #8

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?


#9

Sure. How many seconds before it issues CANCEL? How many seconds before the outgoing leg signals 180 Ringing or 183 Progress?


(Italy) #10

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


(Italy) #11

Like 5-10 seconds to ring, the RTP timeout its way higher than that
CANCEL after a couple seconds


#12

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.


(David55) #13

If you are getting a CANCEL, any RTP timeout will be implemented by the upstream system, so the FreePBX/Asterisk RTP timeout will be irrelevant.

I believe the suggestion, above, to see if in band progress helps, was based on the possibility that the upstream is imposing an RTP timeout


(system) closed #14

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