Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


No Format
exten => external_replaces,1,NoOp()
	same => n,Dial(PJSIP/default_outgoing/${SIPREFERTOHDR})

Let's examine that Dial() more closely. First, we're dialing using PJSIP, which is pretty obvious. Next, we have the endpoint name. The endpoint name could be any configured endpoint you want to use to make this call. Remember that endpoint settings are things such as what codecs to use, what user name to place in the from header, etc. By default, if you just dial PJSIP/some_endpoint, Asterisk looks at some_endpoint's configured aors to determine what location to send the outgoing call to. However, you can override this default behavior and specify a URI to send the call to instead. This is what is being done in this Dial() statement. We're dialing using settings for an endpoint called "default_outgoing", presumably used as a default endpoint for outgoing calls. We're sending the call out to the URI specified by SIPREFERTOHDR though. Using the scenario on this page, the Dial() command would route the call to sip:carol@server_b.

This will create automatically place the Replaces Header in the INVITE.

Accepting INVITEs of Remote Attended Transfers

In the above example lets say Server B is also running Asterisk and you want to accept the attended transfer you've just placed to it from your external_replaces extension as above (or perhaps you've another SIP device sending a transfer this way to Asterisk).

When Server B's pjsip recieves the INVITE, lets say, continuing from the Dial() in the above example, to carol@server_b, it'll first check that the extension exists before it checks the Replaces header. This means that you need to ensure that this extension (carol) exists in the context associated with the endpoint of Server A, otherwise the call will simply be rejected, regardless of if the call referenced in the Replaces header matches an active call. In reality if all works as needed, this extension in the dialplan will never actually be hit. Assuming that the extension exists, pjsip will now check if the call referenced in the Replaces header exists and is in a valid state. Assuming a valid existing call can be matched then this new INVITE will be accepted and simply take over that call. It'll never actually hit the extension in the dialplan, at least not initially. Asterisk will hangup the call references (in this example, the call from Bob to Server B), and then Carol's call will be bridged to the new call, that being the call to Server A (which is in turn bridged to Alice on Server A). Re-INVITEs will be sent as required to ensure that the SDP all gets sent to the right place.

If a valid call can't be found matching the Replaces header, then the call will hit the extension in the dialplan (carol) and proceed like a normal INVITE. You could handle this by allow a new call to be placed to the extension, although this may be confusing for users and likely means something has gone wrong. In the example, Carol would still have an active call, and then start getting a new call through. An alternative is to send calls in the external_replaces extension Dial command to a specific destination on Server B, for example "replaces", where you could simply hangup or play a message notifying the user that something's gone wrong.

Avoiding Remote Attended Transfers