0
votes

Using ther Asterisk API I can redirect the To channel to an extension with or without a context.

If I try to redirect the From channel to an extension, the call is terminated unless the context is set to "default".

Why is this?

See also these questions about context and Asterisk.

Why would originate call fail when using the Asterisk API with the Context set to "default"?

https://stackguides.com/questions/10860456/why-would-redirect-fail-when-using-the-asterisk-api-to-call-an-outside-line

2

2 Answers

0
votes

I believe you must specify the context at all times.

In a working example I use:

fputs($socket, "Action: Redirect\r\n");
fputs($socket, "ActionID: $actionID\r\n");
fputs($socket, "Channel: $channel\r\n");
fputs($socket, "Context: agents\r\n");
fputs($socket, "Exten: customHangup\r\n");
fputs($socket, "Priority: 1\r\n\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");       // Log off

(Note that this is PHP sending to socket)

No need to specify the Channel:, Context:, Exten: and Priority:

0
votes

In my experience, I think actually the redirection not forwarding or transferring a channel to one extension. Its actually redirecting the sequence of dialplan execution. So by redirecting you have to specify destination context,extension,priority. So that the redirected call take the appropriate call and execute. Unless you specify the context the it may take the default one. If no matching found I think it may disconnected. I think this may be happen to you. It may be identified from the asterisk CLI. I have one another problem when redirecting form one to another context first forwarding extensions hangup only arrive after complete conversation including forwarded extension.

my dialplan as follows:

[forwarding]
;callforwarding
exten => _XXXX,1,Answer()
same  => n,Dial(SIP/${EXTEN})
same  => n,Hangup()

[external]

exten => _XXXX,1,Answer()
same  => n,Dial(SIP/${EXTEN})
same  => n,Hangup()

AMI redirect action(php):

$msg="Action: Redirect\r\n";
$msg.="Exten: $ToExten\r\n";
$msg.="Context: forwarding\r\n";
$msg.="Priority: 1\r\n";
$msg.="Channel: $channel\r\n\r\n";
fputs($this->amisocket, $msg);

My issue: Hangup not receiving in time asterisk ami