[asterisk-users] ${HANGUPCAUSE} is always 0 in the h extension

Vardan hvardan71 at gmail.com
Tue May 11 05:39:32 CDT 2010


That is normal.
In any case, if the one of call party is hangup, then you take the 
hangupcase 16 - normal call clearing.

But if you want to see who is was terminatet the call, you must look in 
h in boot leg of the call, incoming and outgoing. and so you can see who 
is hangup the call.
I think you can understand what I have write. In this case I can see who 
has hang up call, and the billsec for both side.
This is with FailOver call.


Look my dial plan in ael, I use this with this call out files:
==================================================================
Channel: local/CallToCustomer at c2c_C2CustomerVIAVendors/n
Callerid: 18185402021
WaitTime: 45
MaxRetries: 0
RetryTime: 10
Account: AGENT1
Context: c2c_C2AgentsVIAVendors
Extension: 18185402021
Priority: 1
Setvar: CUSTOMERPEER="ToVendor3-ToVendor4"
Setvar: AGENTPEER="ToVendor1-ToVendor2"
Setvar: CUSTOMERPHONE=37410219709
Setvar: AGENTPHONE=18185402021
Setvar: AGENTTECH=SIP
Setvar: CUSTOMERTECH=SIP
Archive: yes



Dialplan in AEL:
=======================
context c2c_C2CustomerVIASIP {

     _CallToCustomer => {
         Dial(SIP/${CUSTOMER}@${EXTEN});
         Hangup;
     };

};

context c2c_C2CustomerVIAVendors {

     _CallToCustomer => {
         CALLERID(all)=${AGENTPHONE}; Noop(${CALLERID(number)});
 
&FailOverDial(${CUSTOMERTECH},${CUSTOMERPEER},${CUSTOMERPHONE},${CONTEXT});
         Noop(CustomerVIAVerdors == return from macro);
         Hangup;
     };

     h => { Noop(Hangup in c2c_C2CustomerVIAVendors );
         Noop(: Duration of the call once it was answered.${CDR(billsec)});
     };
};


context c2c_C2AgentsVIASIP {

     _CallToCustomer => {
         Dial(SIP/${AGENT}@${EXTEN});
         Hangup;
     };

};

context c2c_C2AgentsVIAVendors {

     _CallToCustomer => {
         CALLERID(all)=${CUSTOMERPHONE}; Noop(${CALLERID(number)});
         &FailOverDial(${AGENTTECH},${AGENTPEER},${AGENTPHONE},${CONTEXT});
         Noop(AgentsVIAVendors === return from macro);
         Hangup;
     };
     _X. => {
         CALLERID(all)=${CUSTOMERPHONE}; Noop(${CALLERID(number)});
         &FailOverDial(${AGENTTECH},${AGENTPEER},${AGENTPHONE},${CONTEXT});
         Noop(AgentsVIAVendors === return from macro);
         Hangup;
     };

     h => { Noop(Hangup in c2c_AgentsVIAVendors );
     Noop(: Duration of the call once it was answered.${CDR(billsec)});
     Hangup;
     };

};


macro FailOverDial (tech,peers,phone,cont) {
     i=1; focount=0;
     Set(j=${CUT(peers,,${i})});
     leng=${LEN(${j})};
     noop(Tech:${tech}); noop(Peers:${peers}); noop(Phone:${phone}); 
noop(J:${j});

     while ( ${leng} > 0 ) {
         Noop(${tech}/${phone}@${j});
         Dial(${tech}/${phone}@${j});
         Noop(Dial status:${DIALSTATUS});
         Noop(End dial command);

         switch(${DIALSTATUS}) {
             case BUSY:
                 Noop(Busy);
                 return;

             case CHANUNAVAIL:
                 Noop(Channel unavailble);
                 i=${i}+1;
                 Set(j=${CUT(peers,,${i})});
                 leng=${LEN(${j})};
                 noop(J:${j});
                 break;

             case NOANSWER:
                 Noop(No answer);
                     return;

             case CANCEL:
                 Noop(Cancel);
                     return;

             case CONGESTION:
                 Noop(Congestion);
                 i=${i}+1;
                 Set(j=${CUT(peers,,${i})});
                 leng=${LEN(${j})};
                 break;

             case ANSWER:
                 Noop(================ Answer);
                     return;

             default:
                 Noop(Defaul);
                     return;
         };
     };
     catch h {
     Noop(Hagup in macro);
     Noop(: Duration of the call once it was answered.${CDR(billsec)});
     Noop(Hangup for context:${cont});
     &ShowCDRDetails();
     Hangup;
     return;
     };
     return;
};

macro ShowCDRDetails () {


         Noop(Hangup in macro);
         Noop(: The channel's account code:${CDR(accountcode)});
         Noop(: DOCUMENTATION, BILL, IGNORE etc:${CDR(amaflags)});
         Noop(: Time the call was answered:${CDR(answer)});
         Noop(: Duration of the call once it was answered.${CDR(billsec)});
         Noop(: Channel name:${CDR(channel)});
         Noop(: Caller ID:${CDR(clid)});
         Noop(: Destination context:${CDR(dcontext)});
         Noop(: ANSWERED, NO ANSWER, BUSY:${CDR(disposition)});
         Noop(: Destination:${CDR(dst)});
         Noop(: Destination channel:${CDR(dstchannel)});
         Noop(: Duration of the call:${CDR(duration)});
         Noop(: Time the call ended:${CDR(end)});
         Noop(: Last app executed:${CDR(lastapp)});
         Noop(: Last app's arguments:${CDR(lastdata)});
         Noop(: Source:${CDR(src)});
         Noop(: Time the call started:${CDR(start)});
         Noop(: The channel's unique id:${CDR(uniqueid)});
         return;
};




Zhang Shukun wrote:
> this is dialplan:
>
> exten =>  123,1,Dial(SIP/1000,10,L(10000))
> exten =>  123,2,NoOp(HANGUPCAUSE is ${HANGUPCAUSE})
>
> this is the log which hangup by caller:
> == Using SIP RTP CoS mark 5
>      -- Executing [123 at 95040:1] Dial("SIP/1001-00000031",
> "SIP/1000,10,L(10000)") in new stack
>      -- Setting call duration limit to 10.000 seconds.
>    == Using SIP RTP CoS mark 5
>      -- Called 1000
>      -- SIP/1000-00000032 is ringing
>      -- SIP/1000-00000032 answered SIP/1001-00000031
>      -- Executing [h at 95040:1] Playback("SIP/1001-00000031",
> "vm-goodbye") in new stack
> [May 11 17:23:16] WARNING[4258]: file.c:750 ast_readaudio_callback:
> Failed to write frame
>      --<SIP/1001-00000031>  Playing 'vm-goodbye.gsm' (language 'en')
> [May 11 17:23:16] WARNING[4258]: app_playback.c:471 playback_exec:
> ast_streamfile failed on SIP/1001-00000031 for vm-goodbye
>      -- Executing [h at 95040:2] NoOp("SIP/1001-00000031", "HANGUPCAUSE is
> 16") in new stack
>    == Spawn extension (95040, 123, 1) exited non-zero on 'SIP/1001-00000031'
>
>
>
> this is the log which hangup by callee:
>
>     == Using SIP RTP CoS mark 5
>      -- Executing [123 at 95040:1] Dial("SIP/1001-00000033",
> "SIP/1000,10,L(10000)") in new stack
>      -- Setting call duration limit to 10.000 seconds.
>    == Using SIP RTP CoS mark 5
>      -- Called 1000
>      -- SIP/1000-00000034 is ringing
>      -- SIP/1000-00000034 answered SIP/1001-00000033
>      -- Executing [h at 95040:1] Playback("SIP/1001-00000033",
> "vm-goodbye") in new stack
>      --<SIP/1001-00000033>  Playing 'vm-goodbye.gsm' (language 'en')
>      -- Executing [h at 95040:2] NoOp("SIP/1001-00000033", "HANGUPCAUSE is
> 16") in new stack
>    == Spawn extension (95040, 123, 1) exited non-zero on 'SIP/1001-00000033'
>
>
> 2010/5/11 Vardan<hvardan71 at gmail.com>:
>> Can you show your dialplan part for that call and log also please
>>
>> Thanks
>>
>> Zhang Shukun wrote:
>>> thank you for reply.
>>>
>>> but hangupcause cant different whether caller hangup or callee hangup?
>>>
>>> above two situation both return 16.
>>>
>>> 2010/5/11 Vardan<hvardan71 at gmail.com>:
>>>> Asterisk variable hangupcause
>>>> Page Contents
>>>>
>>>>       * Asterisk variable Hangupcause
>>>>             o Recommended SIP<->    ISDN Cause codes (from RFC3398):
>>>>             o PRI Hangup Codes
>>>>             o Version notes
>>>>             o Tip
>>>>             o Examples
>>>>                   + Example 1
>>>>                   + Example 2
>>>>                   + Example 3: Macro for handling hangupcause
>>>>                   + Example 4: Set the hangup cause text to a variable
>>>>             o See also
>>>>
>>>>
>>>> Asterisk variable Hangupcause
>>>> Hangupcause is the latest PRI hangup return code on a zap channel
>>>> connected to a PRI interface. Note that this also works on SIP channels,
>>>> maybe other channels as well.
>>>> Tip: The packet isdnutils contains a utility called isdncause that
>>>> provides a textual explanation of the error number that you feed it with
>>>> (watch the entry format).
>>>>
>>>> Previous to CVS 2004-08-12:
>>>>
>>>>    From causes.h:
>>>>    #define AST_CAUSE_NOTDEFINED    0
>>>>    #define AST_CAUSE_NORMAL        1
>>>>    #define AST_CAUSE_BUSY          2
>>>>    #define AST_CAUSE_FAILURE       3
>>>>    #define AST_CAUSE_CONGESTION    4
>>>>    #define AST_CAUSE_UNALLOCATED   5
>>>>
>>>>
>>>> For CVS head releases after 2004-08-12:
>>>>
>>>>    /* Causes for disconnection (from Q.931) */
>>>>    #define AST_CAUSE_UNALLOCATED 1
>>>>    #define AST_CAUSE_NO_ROUTE_TRANSIT_NET 2
>>>>    #define AST_CAUSE_NO_ROUTE_DESTINATION 3
>>>>    #define AST_CAUSE_CHANNEL_UNACCEPTABLE 6
>>>>    #define AST_CAUSE_CALL_AWARDED_DELIVERED 7
>>>>    #define AST_CAUSE_NORMAL_CLEARING 16
>>>>    #define AST_CAUSE_USER_BUSY 17
>>>>    #define AST_CAUSE_NO_USER_RESPONSE 18
>>>>    #define AST_CAUSE_NO_ANSWER 19
>>>>    #define AST_CAUSE_CALL_REJECTED 21
>>>>    #define AST_CAUSE_NUMBER_CHANGED 22
>>>>    #define AST_CAUSE_DESTINATION_OUT_OF_ORDER 27
>>>>    #define AST_CAUSE_INVALID_NUMBER_FORMAT 28
>>>>    #define AST_CAUSE_FACILITY_REJECTED 29
>>>>    #define AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY 30
>>>>    #define AST_CAUSE_NORMAL_UNSPECIFIED 31
>>>>    #define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION 34
>>>>    #define AST_CAUSE_NETWORK_OUT_OF_ORDER 38
>>>>    #define AST_CAUSE_NORMAL_TEMPORARY_FAILURE 41
>>>>    #define AST_CAUSE_SWITCH_CONGESTION 42
>>>>    #define AST_CAUSE_ACCESS_INFO_DISCARDED 43
>>>>    #define AST_CAUSE_REQUESTED_CHAN_UNAVAIL 44
>>>>    #define AST_CAUSE_PRE_EMPTED 45
>>>>    #define AST_CAUSE_FACILITY_NOT_SUBSCRIBED   50
>>>>    #define AST_CAUSE_OUTGOING_CALL_BARRED      52
>>>>    #define AST_CAUSE_INCOMING_CALL_BARRED      54
>>>>    #define AST_CAUSE_BEARERCAPABILITY_NOTAUTH 57
>>>>    #define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL     58
>>>>    #define AST_CAUSE_BEARERCAPABILITY_NOTIMPL 65
>>>>    #define AST_CAUSE_CHAN_NOT_IMPLEMENTED      66
>>>>    #define AST_CAUSE_FACILITY_NOT_IMPLEMENTED      69
>>>>    #define AST_CAUSE_INVALID_CALL_REFERENCE 81
>>>>    #define AST_CAUSE_INCOMPATIBLE_DESTINATION 88
>>>>    #define AST_CAUSE_INVALID_MSG_UNSPECIFIED   95
>>>>    #define AST_CAUSE_MANDATORY_IE_MISSING 96
>>>>    #define AST_CAUSE_MESSAGE_TYPE_NONEXIST 97
>>>>    #define AST_CAUSE_WRONG_MESSAGE 98
>>>>    #define AST_CAUSE_IE_NONEXIST 99
>>>>    #define AST_CAUSE_INVALID_IE_CONTENTS 100
>>>>    #define AST_CAUSE_WRONG_CALL_STATE 101
>>>>    #define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE 102
>>>>    #define AST_CAUSE_MANDATORY_IE_LENGTH_ERROR 103
>>>>    #define AST_CAUSE_PROTOCOL_ERROR 111
>>>>    #define AST_CAUSE_INTERWORKING 127
>>>>    /* Special Asterisk aliases */
>>>>    #define AST_CAUSE_BUSY  AST_CAUSE_USER_BUSY
>>>>    #define AST_CAUSE_FAILURE  AST_CAUSE_NETWORK_OUT_OF_ORDER
>>>>    #define AST_CAUSE_NORMAL  AST_CAUSE_NORMAL_CLEARING
>>>>    #define AST_CAUSE_NOANSWER   AST_CAUSE_NO_ANSWER
>>>>    #define AST_CAUSE_CONGESTION   AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
>>>>    #define AST_CAUSE_NOTDEFINED  0
>>>>
>>>>
>>>>
>>>> Note: This does not work in 0.7.1 (maybe other versions) See:
>>>> http://bugs.digium.com/bug_view_page.php?bug_id=0000890
>>>>
>>>> Recommended SIP<->    ISDN Cause codes (from RFC3398):
>>>>
>>>>     ISUP Cause value                        SIP response
>>>>     ----------------                        ------------
>>>>     1  unallocated number                   404 Not Found
>>>>     2  no route to network                  404 Not found
>>>>     3  no route to destination              404 Not found
>>>>     16 normal call clearing                 --- (*)
>>>>     17 user busy                            486 Busy here
>>>>     18 no user responding                   408 Request Timeout
>>>>     19 no answer from the user              480 Temporarily unavailable
>>>>     20 subscriber absent                    480 Temporarily unavailable
>>>>     21 call rejected                        403 Forbidden (+)
>>>>     22 number changed (w/o diagnostic)      410 Gone
>>>>     22 number changed (w/ diagnostic)       301 Moved Permanently
>>>>     23 redirection to new destination       410 Gone
>>>>     26 non-selected user clearing           404 Not Found (=)
>>>>     27 destination out of order             502 Bad Gateway
>>>>     28 address incomplete                   484 Address incomplete
>>>>
>>>>
>>>> Zhang Shukun wrote:
>>>>> hi , all
>>>>>
>>>>>        i want to wtite hangupcause to cdr, but both caller hangup and
>>>>> callee hangup result in hangupcause code 16.
>>>>>
>>>>> how would i know whether caller or callee or system error hangup the phone?
>>>>>
>>>>> please help.
>>>>>
>>>>> thanks!
>>>>>
>>>>> 2010/4/22 Alejandro Recarey<alexrecarey at gmail.com>:
>>>>>>> However, as I can see by the verbose command, ${HANGUPCAUSE} is always
>>>>>>> 0. I thought it was a channel variable that contained the hangupcause?
>>>>>>
>>>>>> Just an update, if the call is established, then there is a
>>>>>> hangupcause received.
>>>>>>
>>>>>> The above problem only happens if the caller hangs up before pickup.
>>>>>>
>>>>>> This is usualy a cause 16, not 0.
>>>>>>
>>>>>> Alex
>>>>>>
>>>>>> --
>>>>>> _____________________________________________________________________
>>>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>>>>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>>>>>                  http://www.asterisk.org/hello
>>>>>>
>>>>>> asterisk-users mailing list
>>>>>> To UNSUBSCRIBE or update options visit:
>>>>>>      http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> _____________________________________________________________________
>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>>>                 http://www.asterisk.org/hello
>>>>
>>>> asterisk-users mailing list
>>>> To UNSUBSCRIBE or update options visit:
>>>>     http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>> _____________________________________________________________________
>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>                http://www.asterisk.org/hello
>>
>> asterisk-users mailing list
>> To UNSUBSCRIBE or update options visit:
>>    http://lists.digium.com/mailman/listinfo/asterisk-users
>>
>
>
>




More information about the asterisk-users mailing list