<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 22/08/13 15:43, Mordechay Kaganer wrote:
<blockquote
cite="mid:CA+xOVSNy_4U6BPULbSwtEtKASRKXDmt+3Px0fyVnf_v_2ZHkDg@mail.gmail.com"
type="cite">
<div dir="ltr">B.H.
<div><br>
</div>
<div>Hello, i'm using AMI Originate action (with async=true) to
send outgoing calls to a SIP trunk (using asterisk-java
library to connect to AMI).</div>
<div><br>
</div>
<div>The problem is that in case of failed originate,
OriginateResponse event is returning only the reason code
which is sometimes not sufficient to determine the real cause
of failure. Also, there's no way to link between the channel
that was trying to dial and failed and the original Originate
request, because OriginateResponse is issued only after the
failed channel was hang up. Only successful OriginateResponse
will contain the unique id of the established channel.</div>
<div><br>
</div>
<div>Is there any way that my AMI application can get the
original SIP response of the failed Originate action?</div>
<div><br>
</div>
<div>I'm using Asterisk 1.8.22 and slightly tweaked
asterisk-java (<a moz-do-not-send="true"
href="https://blogs.reucon.com/asterisk-java/">https://blogs.reucon.com/asterisk-java/</a>)
1.0.0.<br clear="all">
<div><br>
</div>
</div>
</div>
</blockquote>
<br>
You could dial a local channel instead and have that then go on and
dial the destination. You will then be able to retrieve the sip
response using something like :-<br>
<br>
[localdial]<br>
exten => _X.,1,Set(ddi=${CUT(EXTEN,,1)})<br>
exten => _X.,n,Set(carrier=${CUT(EXTEN,,2)})<br>
exten => _X.,n,Set(dialtime=${EPOCH})<br>
exten => _X.,n,Set(_MASTERCHANNEL=${CHANNEL})<br>
exten => _X.,n,Dial(SIP/${ddi}@${carrier})<br>
exten =>
_X.,n,Set(SIPcause=${MASTER_CHANNEL(HASH(SIP_CAUSE,${CDR(dstchannel)}))},
Responsetime=$[${EPOCH}-${dialtime}])<br>
exten => _X.,n,Set(SIPcode=${CUT(SIPcause," ",2)})<br>
<br>
However you will need to set "<span style="font-size: x-small;">storesipcause=yes"
in your sip.conf for this to work. It is known to have a
performance hit.<br>
<br>
A better way would be to upgrade Asterisk and use hangup handlers.
The documentation on how to do this in Asterisk 11 is poor and
often wrong. I have written a blog about how we set it up as we
use the feature all the time.<br>
<a class="moz-txt-link-freetext" href="http://gblades.blogspot.co.uk/2013/07/how-to-get-sip-response-code-in.html">http://gblades.blogspot.co.uk/2013/07/how-to-get-sip-response-code-in.html</a><br>
<br>
</span>
</body>
</html>