I have a setup with Asterisk 13. I’m using AMI to originate calls.
The events I receive to an OriginateAction that fails, e.g. SIP 603, comes in random order.
Sometimes I receive OrignateResponse and then Hangup. Sometimes the Hangup event comes before OriginateResponse.
As an example with SIP response 603.
The HangupCause is CallRejected.
OrginateResponse indicates failure with reason Busy.
My current implementation handles both the OriginateResponse and Hangup events.
(I’m currently in the process of upgrading from Asterisk 1.6 and in that version I always received the events in the same order)
If I get the Hangup event first I take action based on the Hangup cause (CallRejected), which according to https://wiki.asterisk.org/wiki/display/AST/Hangup+Cause+Mappings could be returned for 401, 403, 407 and 603 response codes.
I interpret that as an error and not as busy.
If I get the OriginateResponse event first I take action based on the reason. For 603 the reason is busy.
I interpret that as busy.
So dependent on the order of the events I interpret the result of the call as busy or error.
One could argue if 603 is comparable to 401, 403 and 407 or if 603 actually means busy. But I leave that to another dicussion.
What I would know is the proper way to interpret the responses. Should I rely on the OriginateResponse or the Hangup event? Can I be sure to always receive both of them?