[HELP] - Retrieve channel status

Hello everyone,
I’m newbie at asterisk, since I apologize now if I’m creating this topic in the wrong place…
I’m using Asterisk 14.6.2

I have a php application, which makes a connection via a local trunk to a number, when this connection is answered, I connect with an IVR.

In my last interaction in the dial plan, I dial with the option g through the SIP to an X exten.

My question is, when this call is terminated, is there any way to get channel status so that I can identify in php that this call was terminated?
Follows the last dial and log information.

 exten => 1,1,NoOp(CALL)
 same=>n,AGI(/var/www/html/tests_asterisk/return.php,TRANSFER,${id_dialing_list_number},${id_dialing_list})
 same=>n,Dial(SIP/g238/9998,60,g)
 same=>n,Log(NOTICE, ${DIALSTATUS})
 same=>n,Hangup()
    -- Executing [1@ivr:1] NoOp("Local/XXXXXXXXX@to-dialer-00000069;1", "CALL") in new stack
    -- Executing [1@ivr:2] AGI("Local/XXXXXXXXX@to-dialer-00000069;1", "/var/www/html/tests_asterisk/return.php,TRANSFER,,") in new stack
    -- Launched AGI Script /var/www/html/tests_asterisk/return.php
    -- <Local/XXXXXXXXX@to-dialer-00000069;1>AGI Script /var/www/html/tests_asterisk/return.php completed, returning 0
    -- Executing [1@ivr:3] Dial("Local/XXXXXXXXX@to-dialer-00000069;1", "SIP/g238/9998,,g") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/g238/9998
       > 0x7fa9c800a7f0 -- Strict RTP learning after remote address set to: 192.168.0.238:18318
    -- SIP/g238-000000a6 answered Local/XXXXXXXXX@to-dialer-00000069;1
    -- Channel SIP/g238-000000a6 joined 'simple_bridge' basic-bridge <1c0d6b80-e1d0-4b78-acb1-a4666ee91ace>
    -- Channel Local/XXXXXXXXX@to-dialer-00000069;1 joined 'simple_bridge' basic-bridge <1c0d6b80-e1d0-4b78-acb1-a4666ee91ace>
       > Move-swap optimizing Local/XXXXXXXXX@to-dialer-00000069;1 <-- SIP/g43-000000a5.
    -- Channel SIP/g43-000000a5 left 'simple_bridge' basic-bridge <77240d47-ba98-44e8-ae80-9794aa569c1b>
    -- Channel Local/XXXXXXXXX@to-dialer-00000069;1 left 'simple_bridge' basic-bridge <1c0d6b80-e1d0-4b78-acb1-a4666ee91ace>
    -- Channel SIP/g43-000000a5 swapped with Local/XXXXXXXXX@to-dialer-00000069;1 into 'simple_bridge' basic-bridge <1c0d6b80-e1d0-4b78-acb1-a4666ee91ace>
       > Bridge 1c0d6b80-e1d0-4b78-acb1-a4666ee91ace: switching from simple_bridge technology to native_rtp
       > Remotely bridged 'SIP/g43-000000a5' and 'SIP/g238-000000a6' - media will flow directly between them
    -- Channel Local/XXXXXXXXX@to-dialer-00000069;2 left 'simple_bridge' basic-bridge <77240d47-ba98-44e8-ae80-9794aa569c1b>
  == Spawn extension (to-dialer, XXXXXXXXX, 2) exited non-zero on 'Local/XXXXXXXXX@to-dialer-00000069;2'
       > 0x7fa9c800a7f0 -- Strict RTP learning after remote address set to: 192.168.0.238:18318
  == Spawn extension (ivr, 1, 3) exited non-zero on 'Local/XXXXXXXXX@to-dialer-00000069;1'
    -- Channel SIP/g238-000000a6 left 'native_rtp' basic-bridge <1c0d6b80-e1d0-4b78-acb1-a4666ee91ace>
    -- Channel SIP/g43-000000a5 left 'native_rtp' basic-bridge <1c0d6b80-e1d0-4b78-acb1-a4666ee91ace>
localhost*CLI>

You can use the h extension, it gets executed after a call has been terminated, from there you can send a notification to your php script that the calls has been terminated

Or you can use Hangup Handlers to notify external application about the channel state

–Satish Barot

Good morning,
First of all, thank you for the answers. The two answers worked perfectly, I make the calls, and I get the status handles, but I realize it did not work out the way I wanted it to.

In both attempts we can see two “CHANNEL LEFT” at the end, that’s where my operator turned off the call, that’s exactly what I need to send to php, I need to know when the call is active or not after I send it to the “operator” in the other GW

Below is the logs with h extension and using the Hangup Handdles


H Extension

cat full.H-extension.bkp
[2017-10-04 11:21:14.410] VERBOSE[10993] dial.c: Called 111111111@to-dialer
[2017-10-04 11:21:14.410] VERBOSE[10994][C-00000122] pbx.c: Executing [111111111@to-dialer:1] NoOp("Local/111111111@to-dialer-0000009a;2", "Registring call on Dialer - 111111111") in new stack
[2017-10-04 11:21:14.410] VERBOSE[10994][C-00000122] pbx.c: Executing [111111111@to-dialer:2] Dial("Local/111111111@to-dialer-0000009a;2", "SIP/g43/111111111,,g") in new stack
[2017-10-04 11:21:14.411] VERBOSE[10994][C-00000122] netsock2.c: Using SIP RTP CoS mark 5
[2017-10-04 11:21:14.412] VERBOSE[10994][C-00000122] app_dial.c: Called SIP/g43/111111111
[2017-10-04 11:21:17.723] VERBOSE[1436][C-00000122] res_rtp_asterisk.c: 0x7fa9e000af90 -- Strict RTP learning after remote address set to: 192.168.0.43:12510
[2017-10-04 11:21:17.723] VERBOSE[10994][C-00000122] app_dial.c: SIP/g43-000000f4 is making progress passing it to Local/111111111@to-dialer-0000009a;2
[2017-10-04 11:21:17.724] VERBOSE[10993] dial.c: Local/111111111@to-dialer-0000009a;1 is making progress
[2017-10-04 11:21:17.732] VERBOSE[10994][C-00000122] res_rtp_asterisk.c: 0x7fa9e000af90 -- Strict RTP switching to RTP target address 192.168.0.43:12510 as source
[2017-10-04 11:21:19.232] VERBOSE[10994][C-00000122] res_rtp_asterisk.c: 0x7fa9e000af90 -- Strict RTP learning complete - Locking on source address 192.168.0.43:12510
[2017-10-04 11:21:21.127] VERBOSE[10994][C-00000122] app_dial.c: SIP/g43-000000f4 answered Local/111111111@to-dialer-0000009a;2
[2017-10-04 11:21:21.128] VERBOSE[10993] dial.c: Local/111111111@to-dialer-0000009a;1 answered
[2017-10-04 11:21:21.129] VERBOSE[10993][C-00000123] pbx.c: Executing [s@ivr:1] NoOp("Local/111111111@to-dialer-0000009a;1", "CALL IN URA") in new stack
[2017-10-04 11:21:21.129] VERBOSE[10993][C-00000123] pbx.c: Executing [s@ivr:2] AGI("Local/111111111@to-dialer-0000009a;1", "/var/www/html/tests_asterisk/return.php,LISTENING,,") in new stack
[2017-10-04 11:21:21.129] VERBOSE[11016][C-00000122] bridge_channel.c: Channel SIP/g43-000000f4 joined 'simple_bridge' basic-bridge <5680a659-6236-449c-918b-3a8dabfb8af3>
[2017-10-04 11:21:21.137] VERBOSE[10993][C-00000123] res_agi.c: Launched AGI Script /var/www/html/tests_asterisk/return.php
[2017-10-04 11:21:21.147] VERBOSE[10994][C-00000122] bridge_channel.c: Channel Local/111111111@to-dialer-0000009a;2 joined 'simple_bridge' basic-bridge <5680a659-6236-449c-918b-3a8dabfb8af3>
[2017-10-04 11:21:21.234] VERBOSE[10993][C-00000123] res_agi.c: <Local/111111111@to-dialer-0000009a;1>AGI Script /var/www/html/tests_asterisk/return.php completed, returning 0
[2017-10-04 11:21:21.245] VERBOSE[10993][C-00000123] pbx.c: Executing [s@ivr:3] BackGround("Local/111111111@to-dialer-0000009a;1", "tt-monkeys") in new stack
[2017-10-04 11:21:21.246] VERBOSE[10993][C-00000123] file.c: <Local/111111111@to-dialer-0000009a;1> Playing 'tt-monkeys.gsm' (language 'en')
[2017-10-04 11:21:24.597] DTMF[11016][C-00000122] channel.c: DTMF begin '1' received on SIP/g43-000000f4
[2017-10-04 11:21:24.597] DTMF[11016][C-00000122] channel.c: DTMF begin passthrough '1' on SIP/g43-000000f4
[2017-10-04 11:21:24.597] DTMF[10993][C-00000123] channel.c: DTMF begin '1' received on Local/111111111@to-dialer-0000009a;1
[2017-10-04 11:21:24.597] DTMF[10993][C-00000123] channel.c: DTMF begin ignored '1' on Local/111111111@to-dialer-0000009a;1
[2017-10-04 11:21:25.087] DTMF[11016][C-00000122] channel.c: DTMF end '1' received on SIP/g43-000000f4, duration 560 ms
[2017-10-04 11:21:25.087] DTMF[11016][C-00000122] channel.c: DTMF end accepted with begin '1' on SIP/g43-000000f4
[2017-10-04 11:21:25.087] DTMF[11016][C-00000122] channel.c: DTMF end passthrough '1' on SIP/g43-000000f4
[2017-10-04 11:21:25.087] DTMF[10993][C-00000123] channel.c: DTMF end '1' received on Local/111111111@to-dialer-0000009a;1, duration 560 ms
[2017-10-04 11:21:25.087] DTMF[10993][C-00000123] channel.c: DTMF end passthrough '1' on Local/111111111@to-dialer-0000009a;1
[2017-10-04 11:21:25.087] VERBOSE[10993][C-00000123] pbx.c: Executing [1@ivr:1] NoOp("Local/111111111@to-dialer-0000009a;1", "CALL") in new stack
[2017-10-04 11:21:25.087] VERBOSE[10993][C-00000123] pbx.c: Executing [1@ivr:2] AGI("Local/111111111@to-dialer-0000009a;1", "/var/www/html/tests_asterisk/return.php,TRANSFER,,") in new stack
[2017-10-04 11:21:25.095] VERBOSE[10993][C-00000123] res_agi.c: Launched AGI Script /var/www/html/tests_asterisk/return.php
[2017-10-04 11:21:25.190] VERBOSE[10993][C-00000123] res_agi.c: <Local/111111111@to-dialer-0000009a;1>AGI Script /var/www/html/tests_asterisk/return.php completed, returning 0
[2017-10-04 11:21:25.201] VERBOSE[10993][C-00000123] pbx.c: Executing [1@ivr:3] Dial("Local/111111111@to-dialer-0000009a;1", "SIP/g238/9998,,g") in new stack
[2017-10-04 11:21:25.202] VERBOSE[10993][C-00000123] netsock2.c: Using SIP RTP CoS mark 5
[2017-10-04 11:21:25.204] VERBOSE[10993][C-00000123] app_dial.c: Called SIP/g238/9998
[2017-10-04 11:21:25.230] VERBOSE[1436][C-00000123] res_rtp_asterisk.c: 0x7fa9d800c220 -- Strict RTP learning after remote address set to: 192.168.0.238:10656
[2017-10-04 11:21:25.231] VERBOSE[10993][C-00000123] app_dial.c: SIP/g238-000000f5 answered Local/111111111@to-dialer-0000009a;1
[2017-10-04 11:21:25.232] VERBOSE[11031][C-00000123] bridge_channel.c: Channel SIP/g238-000000f5 joined 'simple_bridge' basic-bridge <ee598780-b34c-4cbb-b297-77c3a439104f>
[2017-10-04 11:21:25.233] VERBOSE[10993][C-00000123] bridge_channel.c: Channel Local/111111111@to-dialer-0000009a;1 joined 'simple_bridge' basic-bridge <ee598780-b34c-4cbb-b297-77c3a439104f>
[2017-10-04 11:21:25.237] VERBOSE[10994][C-00000122] bridge.c: Move-swap optimizing Local/111111111@to-dialer-0000009a;1 <-- SIP/g43-000000f4.
[2017-10-04 11:21:25.237] VERBOSE[10994][C-00000122] bridge_channel.c: Channel SIP/g43-000000f4 left 'simple_bridge' basic-bridge <5680a659-6236-449c-918b-3a8dabfb8af3>
[2017-10-04 11:21:25.237] VERBOSE[10994][C-00000122] bridge_channel.c: Channel Local/111111111@to-dialer-0000009a;1 left 'simple_bridge' basic-bridge <ee598780-b34c-4cbb-b297-77c3a439104f>
[2017-10-04 11:21:25.237] VERBOSE[10994][C-00000122] bridge_channel.c: Channel SIP/g43-000000f4 swapped with Local/111111111@to-dialer-0000009a;1 into 'simple_bridge' basic-bridge <ee598780-b34c-4cbb-b297-77c3a439104f>
[2017-10-04 11:21:25.237] VERBOSE[10994][C-00000122] bridge.c: Bridge ee598780-b34c-4cbb-b297-77c3a439104f: switching from simple_bridge technology to native_rtp
[2017-10-04 11:21:25.238] VERBOSE[10994][C-00000122] bridge_native_rtp.c: Remotely bridged 'SIP/g43-000000f4' and 'SIP/g238-000000f5' - media will flow directly between them
[2017-10-04 11:21:25.239] VERBOSE[10994][C-00000122] bridge_channel.c: Channel Local/111111111@to-dialer-0000009a;2 left 'simple_bridge' basic-bridge <5680a659-6236-449c-918b-3a8dabfb8af3>
[2017-10-04 11:21:25.239] VERBOSE[10994][C-00000122] pbx.c: Spawn extension (to-dialer, 111111111, 2) exited non-zero on 'Local/111111111@to-dialer-0000009a;2'
[2017-10-04 11:21:25.241] VERBOSE[10993][C-00000123] pbx.c: Spawn extension (ivr, 1, 3) exited non-zero on 'Local/111111111@to-dialer-0000009a;1'
[2017-10-04 11:21:25.242] VERBOSE[10993][C-00000123] pbx.c: Executing [h@ivr:1] NoOp("Local/111111111@to-dialer-0000009a;1", "Testing the H Extension") in new stack
[2017-10-04 11:21:25.242] VERBOSE[10993][C-00000123] pbx.c: Executing [h@ivr:2] Log("Local/111111111@to-dialer-0000009a;1", "NOTICE, ANSWER") in new stack
[2017-10-04 11:21:25.242] NOTICE[10993][C-00000123] Ext. h:  ANSWER
[2017-10-04 11:21:25.242] VERBOSE[10993][C-00000123] pbx.c: Executing [h@ivr:3] Hangup("Local/111111111@to-dialer-0000009a;1", "") in new stack
[2017-10-04 11:21:25.242] VERBOSE[10993][C-00000123] pbx.c: Spawn extension (ivr, h, 3) exited non-zero on 'Local/111111111@to-dialer-0000009a;1'
[2017-10-04 11:21:25.242] VERBOSE[1436][C-00000123] res_rtp_asterisk.c: 0x7fa9d800c220 -- Strict RTP learning after remote address set to: 192.168.0.238:10656
[2017-10-04 11:21:30.915] VERBOSE[11031][C-00000123] bridge_channel.c: Channel SIP/g238-000000f5 left 'native_rtp' basic-bridge <ee598780-b34c-4cbb-b297-77c3a439104f>
[2017-10-04 11:21:30.916] VERBOSE[11016][C-00000122] bridge_channel.c: Channel SIP/g43-000000f4 left 'native_rtp' basic-bridge <ee598780-b34c-4cbb-b297-77c3a439104f>

Hangup Handlers

cat full.hangup-handlers.bkp
[2017-10-04 11:18:59.932] VERBOSE[10610] dial.c: Called 111111111@to-dialer
[2017-10-04 11:18:59.932] VERBOSE[10611][C-00000120] pbx.c: Executing [111111111@to-dialer:1] NoOp("Local/111111111@to-dialer-00000099;2", "Registring call on Dialer - 111111111") in new stack
[2017-10-04 11:18:59.933] VERBOSE[10611][C-00000120] pbx.c: Executing [111111111@to-dialer:2] Set("Local/111111111@to-dialer-00000099;2", "CHANNEL(hangup_handler_push)=ivr,1,4(args)") in new stack
[2017-10-04 11:18:59.933] VERBOSE[10611][C-00000120] pbx.c: Executing [111111111@to-dialer:3] Dial("Local/111111111@to-dialer-00000099;2", "SIP/g43/111111111,,g") in new stack
[2017-10-04 11:18:59.934] VERBOSE[10611][C-00000120] netsock2.c: Using SIP RTP CoS mark 5
[2017-10-04 11:18:59.934] VERBOSE[10611][C-00000120] app_dial.c: Called SIP/g43/111111111
[2017-10-04 11:19:03.844] VERBOSE[1436][C-00000120] res_rtp_asterisk.c: 0x7fa9b400d730 -- Strict RTP learning after remote address set to: 192.168.0.43:18114
[2017-10-04 11:19:03.844] VERBOSE[10611][C-00000120] app_dial.c: SIP/g43-000000f2 is making progress passing it to Local/111111111@to-dialer-00000099;2
[2017-10-04 11:19:03.844] VERBOSE[10610] dial.c: Local/111111111@to-dialer-00000099;1 is making progress
[2017-10-04 11:19:03.856] VERBOSE[10611][C-00000120] res_rtp_asterisk.c: 0x7fa9b400d730 -- Strict RTP switching to RTP target address 192.168.0.43:18114 as source
[2017-10-04 11:19:05.356] VERBOSE[10611][C-00000120] res_rtp_asterisk.c: 0x7fa9b400d730 -- Strict RTP learning complete - Locking on source address 192.168.0.43:18114
[2017-10-04 11:19:07.482] VERBOSE[10611][C-00000120] app_dial.c: SIP/g43-000000f2 answered Local/111111111@to-dialer-00000099;2
[2017-10-04 11:19:07.482] VERBOSE[10610] dial.c: Local/111111111@to-dialer-00000099;1 answered
[2017-10-04 11:19:07.482] VERBOSE[10610][C-00000121] pbx.c: Executing [s@ivr:1] NoOp("Local/111111111@to-dialer-00000099;1", "CALL IN URA") in new stack
[2017-10-04 11:19:07.482] VERBOSE[10610][C-00000121] pbx.c: Executing [s@ivr:2] AGI("Local/111111111@to-dialer-00000099;1", "/var/www/html/tests_asterisk/return.php,LISTENING,,") in new stack
[2017-10-04 11:19:07.490] VERBOSE[10610][C-00000121] res_agi.c: Launched AGI Script /var/www/html/tests_asterisk/return.php
[2017-10-04 11:19:07.495] VERBOSE[10634][C-00000120] bridge_channel.c: Channel SIP/g43-000000f2 joined 'simple_bridge' basic-bridge <7a35c5dc-181d-45af-98d8-be1fd406b99a>
[2017-10-04 11:19:07.498] VERBOSE[10611][C-00000120] bridge_channel.c: Channel Local/111111111@to-dialer-00000099;2 joined 'simple_bridge' basic-bridge <7a35c5dc-181d-45af-98d8-be1fd406b99a>
[2017-10-04 11:19:07.583] VERBOSE[10610][C-00000121] res_agi.c: <Local/111111111@to-dialer-00000099;1>AGI Script /var/www/html/tests_asterisk/return.php completed, returning 0
[2017-10-04 11:19:07.595] VERBOSE[10610][C-00000121] pbx.c: Executing [s@ivr:3] BackGround("Local/111111111@to-dialer-00000099;1", "tt-monkeys") in new stack
[2017-10-04 11:19:07.595] VERBOSE[10610][C-00000121] file.c: <Local/111111111@to-dialer-00000099;1> Playing 'tt-monkeys.gsm' (language 'en')
[2017-10-04 11:19:10.144] DTMF[10634][C-00000120] channel.c: DTMF begin '1' received on SIP/g43-000000f2
[2017-10-04 11:19:10.144] DTMF[10634][C-00000120] channel.c: DTMF begin passthrough '1' on SIP/g43-000000f2
[2017-10-04 11:19:10.144] DTMF[10610][C-00000121] channel.c: DTMF begin '1' received on Local/111111111@to-dialer-00000099;1
[2017-10-04 11:19:10.144] DTMF[10610][C-00000121] channel.c: DTMF begin ignored '1' on Local/111111111@to-dialer-00000099;1
[2017-10-04 11:19:10.628] DTMF[10634][C-00000120] channel.c: DTMF end '1' received on SIP/g43-000000f2, duration 540 ms
[2017-10-04 11:19:10.628] DTMF[10634][C-00000120] channel.c: DTMF end accepted with begin '1' on SIP/g43-000000f2
[2017-10-04 11:19:10.628] DTMF[10634][C-00000120] channel.c: DTMF end passthrough '1' on SIP/g43-000000f2
[2017-10-04 11:19:10.629] DTMF[10610][C-00000121] channel.c: DTMF end '1' received on Local/111111111@to-dialer-00000099;1, duration 540 ms
[2017-10-04 11:19:10.629] DTMF[10610][C-00000121] channel.c: DTMF end passthrough '1' on Local/111111111@to-dialer-00000099;1
[2017-10-04 11:19:10.629] VERBOSE[10610][C-00000121] pbx.c: Executing [1@ivr:1] NoOp("Local/111111111@to-dialer-00000099;1", "CALL") in new stack
[2017-10-04 11:19:10.629] VERBOSE[10610][C-00000121] pbx.c: Executing [1@ivr:2] AGI("Local/111111111@to-dialer-00000099;1", "/var/www/html/tests_asterisk/return.php,TRANSFER,,") in new stack
[2017-10-04 11:19:10.637] VERBOSE[10610][C-00000121] res_agi.c: Launched AGI Script /var/www/html/tests_asterisk/return.php
[2017-10-04 11:19:10.725] VERBOSE[10610][C-00000121] res_agi.c: <Local/111111111@to-dialer-00000099;1>AGI Script /var/www/html/tests_asterisk/return.php completed, returning 0
[2017-10-04 11:19:10.736] VERBOSE[10610][C-00000121] pbx.c: Executing [1@ivr:3] Dial("Local/111111111@to-dialer-00000099;1", "SIP/g238/9998,,g") in new stack
[2017-10-04 11:19:10.738] VERBOSE[10610][C-00000121] netsock2.c: Using SIP RTP CoS mark 5
[2017-10-04 11:19:10.739] VERBOSE[10610][C-00000121] app_dial.c: Called SIP/g238/9998
[2017-10-04 11:19:10.755] VERBOSE[1436][C-00000121] res_rtp_asterisk.c: 0x7fa9b800e5e0 -- Strict RTP learning after remote address set to: 192.168.0.238:13546
[2017-10-04 11:19:10.756] VERBOSE[10610][C-00000121] app_dial.c: SIP/g238-000000f3 answered Local/111111111@to-dialer-00000099;1
[2017-10-04 11:19:10.757] VERBOSE[10644][C-00000121] bridge_channel.c: Channel SIP/g238-000000f3 joined 'simple_bridge' basic-bridge <ddfe251e-701a-4263-8658-859fa50f3488>
[2017-10-04 11:19:10.757] VERBOSE[10610][C-00000121] bridge_channel.c: Channel Local/111111111@to-dialer-00000099;1 joined 'simple_bridge' basic-bridge <ddfe251e-701a-4263-8658-859fa50f3488>
[2017-10-04 11:19:10.760] VERBOSE[10611][C-00000120] bridge.c: Move-swap optimizing Local/111111111@to-dialer-00000099;1 <-- SIP/g43-000000f2.
[2017-10-04 11:19:10.761] VERBOSE[10611][C-00000120] bridge_channel.c: Channel SIP/g43-000000f2 left 'simple_bridge' basic-bridge <7a35c5dc-181d-45af-98d8-be1fd406b99a>
[2017-10-04 11:19:10.761] VERBOSE[10611][C-00000120] bridge_channel.c: Channel Local/111111111@to-dialer-00000099;1 left 'simple_bridge' basic-bridge <ddfe251e-701a-4263-8658-859fa50f3488>
[2017-10-04 11:19:10.761] VERBOSE[10611][C-00000120] bridge_channel.c: Channel SIP/g43-000000f2 swapped with Local/111111111@to-dialer-00000099;1 into 'simple_bridge' basic-bridge <ddfe251e-701a-4263-8658-859fa50f3488>
[2017-10-04 11:19:10.761] VERBOSE[10611][C-00000120] bridge.c: Bridge ddfe251e-701a-4263-8658-859fa50f3488: switching from simple_bridge technology to native_rtp
[2017-10-04 11:19:10.761] VERBOSE[10611][C-00000120] bridge_native_rtp.c: Remotely bridged 'SIP/g43-000000f2' and 'SIP/g238-000000f3' - media will flow directly between them
[2017-10-04 11:19:10.762] VERBOSE[10611][C-00000120] bridge_channel.c: Channel Local/111111111@to-dialer-00000099;2 left 'simple_bridge' basic-bridge <7a35c5dc-181d-45af-98d8-be1fd406b99a>
[2017-10-04 11:19:10.762] VERBOSE[10611][C-00000120] pbx.c: Spawn extension (to-dialer, 111111111, 3) exited non-zero on 'Local/111111111@to-dialer-00000099;2'
[2017-10-04 11:19:10.763] VERBOSE[10611][C-00000120] app_stack.c: Local/111111111@to-dialer-00000099;2 Internal Gosub(ivr,1,4(args)) start
[2017-10-04 11:19:10.763] VERBOSE[10611][C-00000120] pbx.c: Executing [1@ivr:4] NoOp("Local/111111111@to-dialer-00000099;2", "Testing Hangup Handler") in new stack
[2017-10-04 11:19:10.763] VERBOSE[10611][C-00000120] pbx.c: Executing [1@ivr:5] Log("Local/111111111@to-dialer-00000099;2", "NOTICE, ANSWER") in new stack
[2017-10-04 11:19:10.764] NOTICE[10611][C-00000120] Ext. 1:  ANSWER
[2017-10-04 11:19:10.764] VERBOSE[10611][C-00000120] pbx.c: Executing [1@ivr:6] Hangup("Local/111111111@to-dialer-00000099;2", "") in new stack
[2017-10-04 11:19:10.764] VERBOSE[10611][C-00000120] app_stack.c: Spawn extension (ivr, 1, 6) exited non-zero on 'Local/111111111@to-dialer-00000099;2'
[2017-10-04 11:19:10.764] NOTICE[10611][C-00000120] app_stack.c: Local/111111111@to-dialer-00000099;2 Abnormal 'Gosub(ivr,1,4(args))' exit.  Popping routine return locations.
[2017-10-04 11:19:10.766] VERBOSE[10610][C-00000121] pbx.c: Spawn extension (ivr, 1, 3) exited non-zero on 'Local/111111111@to-dialer-00000099;1'
[2017-10-04 11:19:10.767] VERBOSE[1436][C-00000121] res_rtp_asterisk.c: 0x7fa9b800e5e0 -- Strict RTP learning after remote address set to: 192.168.0.238:13546
[2017-10-04 11:19:17.812] VERBOSE[10644][C-00000121] bridge_channel.c: Channel SIP/g238-000000f3 left 'native_rtp' basic-bridge <ddfe251e-701a-4263-8658-859fa50f3488>
[2017-10-04 11:19:17.813] VERBOSE[10634][C-00000120] bridge_channel.c: Channel SIP/g43-000000f2 left 'native_rtp' basic-bridge <ddfe251e-701a-4263-8658-859fa50f3488>

Use AMI (Asterisk Manager Interface) events.

I am using the AMI to originate calls.
Are you telling me to use the AMI at all times to check if the call is active or not?

If you want call status mid-call, AMI is probably the best option. You should be using events, rather than polling.

I need to know when the call is finished.
As with the logs above, the extension has hangup handlers, it does not seem to be working the way I need it, we can see that it works, but it seems like the “h extension” and hangup handlers are following in a different channel from the one that is finalized , is there any way to retrieve the status of this channel?

The only channel that will give you an interesting status is the B side. The A side is already up, so can either survive the B side or will give a normal clearing status.

If you want status on the A side of an originate that fails you need to use a local channel.