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 tried another and simple h extention too but I had the same result.

That’s because it’s not using the dialplan you’ve provided. It is using “from-internal” for a context.

how can i fix it?

Configure 200 in sip.conf to use the proper context.

in sip-additional.conf i change that line:
context=voiping
but it dose not fix yet

Did you reload it? Did you confirm that value was changed? (You can see what is executing for context, extension, and priority in the log output). What happened?

thanks. i reload and it works.
but i think it is not a permanent solution because when i apply config in FreePBX GUI, the sip file changes.
what can i do about that problem?

Are you using a GUI such as FreePBX? If so, then your question is really “how do I make my changes work with the GUI” which I can’t answer.

yes I am using FreePBX. no problem. You have been a great help so far
thanks a lot

I think, more accurately, it is using it but as an inclusion within an inclusion. When you use included code is run in the includer’s context, and form-internal probably defines its own h extension. The OP’s code is being run, but treated as running in from-internal, not the included context name.

Except in special cases, FreePBX questions should be asked on the FreePBX forum as answers here will assume that you have full control of Asterisk, and don’t have hundreds of lines of pre-written dialplan to account for.

hi.
ok tnx.