Asterisk CANCEL message processing when using Originate() app

Hi, I’m facing next situation:

Bob calling to Alice

  1. Asterisk get incoming sip INVITE from Bob
  2. Asterisk create outbound call using Originate(SIP/ext@domain/callerid, exten, context, someextention, 1) app to Alice
  3. Bob send CANCEL message before Alice answer the call
  4. Asterisk send 487 to Bob
  5. Nothing happens until Alice answer the call (Bob’s SIP channel stays open)
  6. Right after Alice answer Bob’s channel execute h extension and disappear but Alice channel being add to confbridge

Problem:

Is there any way I can cancel Originate() app before Alice answer the phone?
(I want Alice phone to stop ringing if Bob CANCEL the call)

Thank’s for any help

Please explain your real objectives, as this is a very convoluted way of initiating a call, and we need to understand why you cannot use Dial.

I’m using macros for some additional functionality for both legs (Bob and Alice) and I’m using Asterisk as gateway, it should stay in the middle of the call, record it and send alerts

So in my example:

Originate(SIP/Alice@domain/callerid, exten, context, Alice-extension, 1) );

 switch ${ORIGINATE_STATUS}{
     case SUCCESS:
         goto Bob-extention;
 }

Bob-extension {
&macro();
confbridge(id);
}

Alice-extension {
&other-macro();
confbridge(id);
}

It looks like Originate() block application until it return some status (Success, Fail or other), and after that it create another thread where Alice-extension executed, but once Originate() return and since Bob CANCEL the call his thread doesn’t process ORIGINATE_STATUS anymore but goes straight to h extension, but Alice thread keep executing logic from Alice-extension.

I need to kill Alice thread (channel) somehow if Bob’s thread (channel) is canceled

Logic done in AEL

Almost certainly you should be using Dial, possibly with the G option, not Originate.

Problem is that I need to add more users to that conversation (confbridge). Can it be done with Dial()?

If you use G with Dial, you have dialplan running on both channels after the call is answered, and they can find each other using channel variables.