Hi. I'm making calls via the Manager OriginateAction. My action is set to be async and therefore I receive originiate events. Within the originate event that I receive there is a reason code. In the event of failure I need to dermine why the call failed (no pickup, rejected, no such number, circuit busy, ect) and inform the user with a meaningful message. I assume that one is suppose to determine the failure cause by interpreting the reason code. But the reason is always 1. If the callee does not pickup the reason is 1, if the callee rejects the call the reason is 1, if the number does not exist the reason is 1. If the call was successful the reason is 4. Is this correct behaviour? Am I doing something wrong? What are all the different reason codes? Where can I find a list that explains what all the different codes mean? Are they the same as the hangup causes? If the reason code is not meant to determine failure causes, how else can I determine this? Thanks. Regards, Jan.
Jan. Unfortunately, Originate is somehow a mess. Answering your question, the "reason" is not really a reason, at least not in release 1.2.12.1, that is the one im using. The reason is set according to the last communication frame read from the originated channel. Let me explain. When you originate a channel, asterisk starts creating the internal C structure, and then trying to reach the peer. So, one first common control frame received from our originated channel is AST_CONTROL_RING, defined in include/asterisk/frame.h with a value of 2. If originate terminated in that very moment, the reason would be 2. But in your scenario, when the callee does not pick up, the channel is hangup, so the control frame AST_CONTROL_HANGUP is the last frame read, and YES, is defined with a value of 1, the 1 you always receive. The 4 you receive is defined as AST_CONTROL_ANSWER, because that was the last control frame received once the call was answered and the event OriginateSuccess sent. In my personal experience I have the following code working good enough to handle async originate responses, it has some comments so you can see what other reasons im using: /* Asterisk Control frames are returned to us as "Reason" see: include/asterisk/frame.h for more AST_CONTROL constants * some of them are unlikely to happen, or just not possible * Cause 0 .... Unknown ( Unreachable ( not registered, channel does not exists, channel type unknown etc ) ) * Cause 1 .... HANGUP ( the originated channel was hanged up ) * It seems cause 1 es generated when soft hangup is requested on the ringing channel, or even when the channel * has not ringed at all ( ie. the SIP peer exists, but has not UNREACHABLE status yet ). * So we need to check out if was ever answered. If so, we ignore it, otherwise, we report Unavailable * Cause 5 ( BUSY ) * Cause 8 ( CONGESTION ) as cause 0, Unavailable * */ if ( 0 == $EventData['Reason'] || 8 == $EventData['Reason'] ) { $channel->SetState(IPbxChannel::STATE_UNAVAILABLE); } /* the channel was created but was busy */ elseif ( 5 == $EventData['Reason'] ) { $channel->SetState(IPbxChannel::STATE_BUSY); } /* the channel was hanged up, but never ringing, report Unavailable */ elseif ( 1 == $EventData['Reason'] && !$this->expected_originates[$action_id]['channel']->TestFlag(AsteriskChannel::FLAG_EVER_AVAILABLE) ) { $channel->SetState(IPbxChannel::STATE_UNAVAILABLE); } unset($this->expected_originates[$action_id]); I guess you should dive into the C Asterisk code a while before trying to fill your needs. By the way, have you ever needed to associate the Newchannel event to the originate action? how do you make it? I have made a patch to include the Originate ActionID into the Newchannel event when the newchannel is product of originate action, but is messy, and I have not tested it on all channel technologies, and looking for a non-patch solution. Regards On 10/13/06, Jan du Toit <jan.du.toit@decisionworx.com> wrote:> Hi. > > I'm making calls via the Manager OriginateAction. My action is set to be > async and therefore I receive originiate events. Within the originate > event that I receive there is a reason code. In the event of failure I > need to dermine why the call failed (no pickup, rejected, no such > number, circuit busy, ect) and inform the user with a meaningful > message. I assume that one is suppose to determine the failure cause by > interpreting the reason code. But the reason is always 1. If the callee > does not pickup the reason is 1, if the callee rejects the call the > reason is 1, if the number does not exist the reason is 1. If the call > was successful the reason is 4. Is this correct behaviour? Am I doing > something wrong? > > What are all the different reason codes? Where can I find a list that > explains what all the different codes mean? Are they the same as the > hangup causes? > If the reason code is not meant to determine failure causes, how else > can I determine this? > > Thanks. Regards, Jan. > > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- "Su nombre es GNU/Linux, no solamente Linux, mas info en http://www.gnu.org"
////////////////////////////////////////////////////////////////// hello, I am developing something similar, but not of as I cosay are those that you speak, can say to me as she takes them or of where. The form as I am doing it is reading all the events that socket throws. When receipt the message * "Originate successfully queued" * is because I answer the client. When receipt the message * "Originate failed" *, depending on the time in which it is delayed in giving the answer me I determine if "it is occupied" or "it does not answer". ////////////////////////////////////////////////////////////////// texto original en espa?ol hello, I am developing something similar, but not of as I cosay are those that you speak, can say to me as she takes them or of where. The form as I am doing it is reading all the events that socket throws. When receipt the Originate message successfully queued is because I answer the client. When receipt the Originate message failed, depending on the time in which it is delayed in giving the answer me I determine if "it is occupied" or "it does not answer". //////////////////////////////////////////////////////////////////// texto original en espa?ol hola, yo estoy desarrollando algo parecido, pero no se de cuales codigo son los que usted habla, me podria decir como los toma o de donde. La forma como yo lo estoy haciendo es leyendo todos los eventos que arroja el socket. Cuando recibo el mensaje Originate successfully queued es porque contesto el cliente. Cuando recibo el mensaje Originate failed, dependiendo del tiempo en que se demore en darme la respuesta determino si es "ocupado" o "no contesta". DiegoF On 10/13/06, Jan du Toit <jan.du.toit@decisionworx.com> wrote:> > Hi. > > I'm making calls via the Manager OriginateAction. My action is set to be > async and therefore I receive originiate events. Within the originate > event that I receive there is a reason code. In the event of failure I > need to dermine why the call failed (no pickup, rejected, no such > number, circuit busy, ect) and inform the user with a meaningful > message. I assume that one is suppose to determine the failure cause by > interpreting the reason code. But the reason is always 1. If the callee > does not pickup the reason is 1, if the callee rejects the call the > reason is 1, if the number does not exist the reason is 1. If the call > was successful the reason is 4. Is this correct behaviour? Am I doing > something wrong? > > What are all the different reason codes? Where can I find a list that > explains what all the different codes mean? Are they the same as the > hangup causes? > If the reason code is not meant to determine failure causes, how else > can I determine this? > > Thanks. Regards, Jan. > > _______________________________________________ > --Bandwidth and Colocation provided by Easynews.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- // DiegoF // // Dichosos aquellos que no esperan nada de la vida, porque nunca seran defraudados -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20061013/c045b0ef/attachment.htm
As said by Moises the "reason" in the orginate events is not working in version 1.2.12.1. Does anyobdy know in what version it is working, preferably one later than 1.2.12.1 and not prior to 1.2.5? Is it working correctly in asterisk 1.4?