Asterisk h extension dose not work and it jumps to the hangupcall macro

I have a dialplan like that:

[from-internal-custom]
include => voiping

[voiping]
exten => 5002,1,noop()
exten => 5002,n,agi(senarios/specific-call.php)
exten => 5002,n,hangup()
exten => h,1,agi(senarios/update-table.php)

but when i try a call, hangupcall macro is executed and my call is hangedup.

this is my logs:

[2024-04-22 06:17:21] VERBOSE[7768][C-00000004] netsock2.c: Using SIP RTP TOS bits 184
[2024-04-22 06:17:21] VERBOSE[7768][C-00000004] netsock2.c: Using SIP RTP CoS mark 5
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] pbx.c: Executing [5002@from-internal:1] NoOp("SIP/200-00000008", "") in new stack
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] pbx.c: Executing [5002@from-internal:2] AGI("SIP/200-00000008", "senarios/specific-call.php") in new stack
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] res_agi.c: Launched AGI Script /var/lib/asterisk/agi-bin/senarios/specific-call.php
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] res_agi.c: senarios/specific-call.php: *************** test *********************
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] res_agi.c: senarios/specific-call.php: *************** 200 *********************
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] res_agi.c: senarios/specific-call.php: ************* Extension number from dstchannel(asteriskcdrdb database): 202 *****************
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] res_agi.c: AGI Script Executing Application: (Dial) Options: (SIP/202)
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] netsock2.c: Using SIP RTP TOS bits 184
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] netsock2.c: Using SIP RTP CoS mark 5
[2024-04-22 06:17:21] VERBOSE[17818][C-00000004] app_dial.c: Called SIP/202
[2024-04-22 06:17:22] VERBOSE[17818][C-00000004] app_dial.c: SIP/202-00000009 is ringing
[2024-04-22 06:17:23] VERBOSE[17830] manager.c: Manager 'admin' logged on from 127.0.0.1
[2024-04-22 06:17:23] VERBOSE[17830] manager.c: Manager 'admin' logged off from 127.0.0.1
[2024-04-22 06:17:26] VERBOSE[17818][C-00000004] app_dial.c: SIP/202-00000009 answered SIP/200-00000008
[2024-04-22 06:17:26] VERBOSE[17840][C-00000004] bridge_channel.c: Channel SIP/202-00000009 joined 'simple_bridge' basic-bridge <9be0c0ee-a6b1-4af9-bc10-1930c92325a1>
[2024-04-22 06:17:26] VERBOSE[17818][C-00000004] bridge_channel.c: Channel SIP/200-00000008 joined 'simple_bridge' basic-bridge <9be0c0ee-a6b1-4af9-bc10-1930c92325a1>
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] bridge_channel.c: Channel SIP/200-00000008 left 'simple_bridge' basic-bridge <9be0c0ee-a6b1-4af9-bc10-1930c92325a1>
[2024-04-22 06:17:29] VERBOSE[17840][C-00000004] bridge_channel.c: Channel SIP/202-00000009 left 'simple_bridge' basic-bridge <9be0c0ee-a6b1-4af9-bc10-1930c92325a1>
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] res_agi.c: <SIP/200-00000008>AGI Script senarios/specific-call.php completed, returning 4
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx.c: Spawn extension (from-internal, 5002, 2) exited non-zero on 'SIP/200-00000008'
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx.c: Executing [h@from-internal:1] Macro("SIP/200-00000008", "hangupcall") in new stack
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx.c: Executing [s@macro-hangupcall:1] GotoIf("SIP/200-00000008", "1?theend") in new stack
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx_builtins.c: Goto (macro-hangupcall,s,3)
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx.c: Executing [s@macro-hangupcall:3] ExecIf("SIP/200-00000008", "0?Set(CDR(recordingfile)=)") in new stack
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx.c: Executing [s@macro-hangupcall:4] NoOp("SIP/200-00000008", "SIP/202-00000009 montior file= ") in new stack
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx.c: Executing [s@macro-hangupcall:5] GotoIf("SIP/200-00000008", "1?skipagi") in new stack
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx_builtins.c: Goto (macro-hangupcall,s,7)
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx.c: Executing [s@macro-hangupcall:7] Hangup("SIP/200-00000008", "") in new stack
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] app_macro.c: Spawn extension (macro-hangupcall, s, 7) exited non-zero on 'SIP/200-00000008' in macro 'hangupcall'
[2024-04-22 06:17:29] VERBOSE[17818][C-00000004] pbx.c: Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/200-00000008'

I changed the sip-additional.conf file like that:
context=voiping
and the problem solves.
but it is not a permanent solution because when i apply config in FreePBX GUI, the sip file changes.
any idea?

I was under the impression that this was settable in the GUI, but for customisations of the actual configuration, you should use the sip_custom_post.conf file to try to override the specific setting.

Simply setting it in the explicit parameters, in the GUI, may also work.

chan_sip uses the last definition seen.

Note that chan_sip is a lame duck and you should have a plan, in place, to migrate to chan_pjsip.

hi
tnx a lot
I found that solution:

but I cant modify my own dialplan :slight_smile:

The easiest solution here may be to use a hangup handler, rather than the h extension, but otherwise you need to override the context properly.

Note that overriding the context applies to the caller, not the callee, so is probably a bad idea, as it would, basically, take that caller out of FreePBX.

hi
I solved my problem with custom destination in FreePBX GUI.
tnx a lot

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.