H extension never reached

Hi all !

Good evening.

I have a problem with my dialplan.

In one context, I have several pattern defined. All of them terminated with Hangup().

2 of them are triggering correctly the h extension after hangup but the last one isn’t.

There is nothing special about this third pattern and when adding a NoOp before Hangup, I see that this last function is executed…

The 3 patterns are using Gosub (always terminated with Return()). The one that is not reaching the h is calling several Gosub “in cascade” but that’s the only difference…

Any idea on the issue ?

I could try with hangup handler but I would like to understand the issue.

Thanks in advance for your help !

What I notice.

The 3rd template that doesn’t it the h extension is an attendant menu (allowing user to configure some parameters like exceptional closing message, …).

The attendant is composed of two “cascading” Gosub, those Gosub are mainly composed of Playback() application.

Each Gosub contains a h extension with a Return() application.

If I follow the “full flow” of the attendant, the h extension of the “main” dialplan is executed.

If I stop the execution of the attendant by hanging up “in the middle” then the h extension of the “main” dialplan is never executed (even if Hangup() in [from-internal] is executed…)

How it looks like :

[from-internal]
exten => 370,1,Gosub(service,s,1)
same => n,Hangup()

exten => h,1,NoOp(This is the end)

[service]
exten => s,1,Background(message1)
exten => 1,1,Gosub(sub-service,s,1(1))
same => n,Return()
exten => 2,1,Gosub(sub-service,s,1(2))
same => n,Return()
exten => 3,1,Gosub(sub-service,s,1(3))
same => n,Return()
exten => h,1,Return()

[sub-service]
exten => s,1,Background(message2)
exten => 1,1,SET(FUNC_ODBC1()={ARG1})
same => n,Return()
exten => 1,1,SET(FUNC_ODBC2()={ARG1})
same => n,Return()
exten => h,Return()

If it helps to understand, here is the real execution trace. The last executed statement is the Hangup() from the “main” dialpan…

[2023-11-30 22:53:29]     -- Executing [370@from-vielsalm:1] NoOp("PJSIP/vielsalm-d785-4-0000002e", "service") in new stack
[2023-11-30 22:53:29]     -- Executing [370@from-vielsalm:2] Gosub("PJSIP/vielsalm-d785-4-0000002e", "update-device-state,s,1(INUSE)") in new stack
[2023-11-30 22:53:29]     -- Executing [s@update-device-state:1] Gosub("PJSIP/vielsalm-d785-4-0000002e", "get-channel-name,s,1(PJSIP/vielsalm-d785-4-0000002e)") in new stack
[2023-11-30 22:53:29]     -- Executing [s@get-channel-name:1] Set("PJSIP/vielsalm-d785-4-0000002e", "index=4") in new stack
[2023-11-30 22:53:29]     -- Executing [s@get-channel-name:2] Set("PJSIP/vielsalm-d785-4-0000002e", "index=3") in new stack
[2023-11-30 22:53:29]     -- Executing [s@get-channel-name:3] Return("PJSIP/vielsalm-d785-4-0000002e", "PJSIP/vielsalm-d785-4") in new stack
[2023-11-30 22:53:29]     -- Executing [s@update-device-state:2] Set("PJSIP/vielsalm-d785-4-0000002e", "target_exten=301") in new stack
[2023-11-30 22:53:29]     -- Executing [s@update-device-state:3] GotoIf("PJSIP/vielsalm-d785-4-0000002e", "0?end") in new stack
[2023-11-30 22:53:29]     -- Executing [s@update-device-state:4] Set("PJSIP/vielsalm-d785-4-0000002e", "DEVICE_STATE(Custom:301)=INUSE") in new stack
[2023-11-30 22:53:29]     -- Executing [s@update-device-state:5] Return("PJSIP/vielsalm-d785-4-0000002e", "") in new stack
[2023-11-30 22:53:29]     -- Executing [370@from-vielsalm:3] Gosub("PJSIP/vielsalm-d785-4-0000002e", "service,s,1(from-vielsalm)") in new stack
[2023-11-30 22:53:29]     -- Executing [s@service:1] NoOp("PJSIP/vielsalm-d785-4-0000002e", "from-vielsalm") in new stack
[2023-11-30 22:53:29]     -- Executing [s@service:2] Set("PJSIP/vielsalm-d785-4-0000002e", "to_context=from-external-vielsalm") in new stack
[2023-11-30 22:53:29]     -- Executing [s@service:3] GotoIf("PJSIP/vielsalm-d785-4-0000002e", "0?:get-exceptional-message") in new stack
[2023-11-30 22:53:29]     -- Goto (service,s,5)
[2023-11-30 22:53:29]     -- Executing [s@service:5] Set("PJSIP/vielsalm-d785-4-0000002e", "exceptional_message=exceptional-am") in new stack
[2023-11-30 22:53:29]     -- Executing [s@service:6] GotoIf("PJSIP/vielsalm-d785-4-0000002e", "0?none:exceptional_message") in new stack
[2023-11-30 22:53:29]     -- Goto (service,s,9)
[2023-11-30 22:53:29]     -- Executing [s@service:9] BackGround("PJSIP/vielsalm-d785-4-0000002e", "fr/flexia/exceptional-am-active-status") in new stack
[2023-11-30 22:53:29]        > 0x7f5f2004b440 -- Strict RTP learning after remote address set to: 192.168.2.164:49196
[2023-11-30 22:53:29]     -- <PJSIP/vielsalm-d785-4-0000002e> Playing 'fr/flexia/exceptional-am-active-status.slin' (language 'fr')
[2023-11-30 22:53:30]        > 0x7f5f2004b440 -- Strict RTP qualifying stream type: audio
[2023-11-30 22:53:30]        > 0x7f5f2004b440 -- Strict RTP switching source address to 91.179.112.248:49196
[2023-11-30 22:53:32]   == Spawn extension (service, s, 9) exited non-zero on 'PJSIP/vielsalm-d785-4-0000002e'
[2023-11-30 22:53:32]     -- Executing [h@service:1] Return("PJSIP/vielsalm-d785-4-0000002e", "") in new stack
[2023-11-30 22:53:32]     -- Executing [370@from-vielsalm:4] Hangup("PJSIP/vielsalm-d785-4-0000002e", "") in new stack
[2023-11-30 22:53:32]   == Spawn extension (from-vielsalm, 370, 4) exited non-zero on 'PJSIP/vielsalm-d785-4-0000002e'
pbx*CLI>

looking at your output Asterisk is executing you h extension but it is not working as you are expeting

exten h,1,Return()
you shold never use this as that will only create ghost calls
change them to
exten => h,1,NoOp(This is the end of ${CONTEXT})

Hi and thanks for your feedback!

Based on your comment, I implemented the same logic in h extension in the two Gosub than in the main part and it seems to work !

The h extension is calling also a Gosub method that set back the custom device state to NOT_INUSE.

Deeper testing planned during the week-end :grin:

Thanks again!

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