`g` flag in Dial command is not triggering when the called party hangs up

Using two FreePBX FPBX- instances. PJSIP trunk between them. One is used as a call generator and one is used as call answerer. The call answerer is a simulated 911 PSAP. The call generator is to be used to simulate “typical” 911 callers and also various 911 system attackers (abusive harassing callers, bot callers, …etc).

I am using a LOCAL channel to launch calls to the call generator. I am providing a channel variable to stipulate how many times a given caller is to call 911. I want to place a call and detect when the called party (i.e. a 911 call taker) hangs up. At hang-up by the call-taker, if this particular caller has not yet placed the max number of calls it is permitted, I wish to repeat the Dial command, wait for the call-taker to answer and eventually hang-up… and so on until the max number of calls have been placed by this caller.

As the topic of this post reflects, the g flag on the Dial command is NOT being triggered by the called party hanging up. I see the BYE request from the call answering PBX. The call gen replies with a 200 OK to the BYE request. Debug shows reception of the BYE and onset of several hangup events (e.g. HangupRequest, SoftHangupRequest, Hangup, DialEnd, …etc). It certainly seems that these events are sufficient to trigger the g flag of the Dial command and proceed to execute the next dialplan statement in the context being executed.

The call record I drop in asterisk’s outgoing folder:

Channel: LOCAL/[email protected]/n
CallerID: 5617672434
Extension: 9111010001
Context: 911-sim-calls
Priority: 1
Setvar: PSAP_MNEMONIC=wspbpdtcp

The dialplan in file extensions_custom.conf I’ve been playing around with.

Note the optional g flag is present in the Dial command.

exten => _9111010001,1,Set(NUM_CALLS=0)

exten => _9111010001,2,NoOp(Caller matched 9111010001 bot caller pattern. Call and stay on line as long as the call-taker doesn’t hang up. If call-taker hangs up, repeat ${MAX_NUM_CALLS} time. Extension to dial = ${EXTEN}, CID is ${CALLERID(num)}.)

exten => _9111010001,3,Set(NUM_CALLS=$[${NUM_CALLS} + 1])
exten => _9111010001,4,Verbose(NUM_CALLS = ${NUM_CALLS})
exten => _9111010001,5,Verbose(MAX_NUM_CALLS = ${MAX_NUM_CALLS})
exten => _9111010001,6,Verbose(NUM_CALLS > MAX_NUM_CALLS = $[ ${NUM_CALLS} > ${MAX_NUM_CALLS}])
exten => _9111010001,7,GotoIf($[ ${NUM_CALLS} > ${MAX_NUM_CALLS}]?endcall)
exten => _9111010001,8,Dial(PJSIP/${PSAP_MNEMONIC}@call-sim-911-trunk,300,gA(spam))
exten => _9111010001,9,Verbose(Reached dialplan statement after Dial command)
exten => _9111010001,10,Goto(911-sim-calls,9111010001,3)
exten => _9111010001,11(endcall),Hangup()

I’ve searched this forum and elsewhere for a couple of days on-line and have not found anyone else who is encountering this issue where apparently the g flag is not triggering despite the called party hanging up.

Any insight from asterisk and or FreePBX experts would be appreciated.

I did have a lower case g in the topic title, but I see that it was promoted to upper case. And a capital G is a different flag. But this topic is in regard to the lower case g flag.

[title fixed - mod]

To make sure we’re on the same page, the g option allows the caller to continue the dialplan (not the callee) if the caller terminates the call before the callee Asterisk will not proceed to the next line.

Can you please share a call trace? Please post a pastebin link, see instructions: https://wiki.freepbx.org/display/SUP/Providing+Great+Debug#ProvidingGreatDebug-AsteriskLogs-PartII

Also, in the future, if you post snippets of your dialplan, please use preformatted text to format them properly…

PitzKey, Thank you very much for your attention and replying to my post.

Yes - I believe we are on the same page as you will see in the log you have requested. The called FreePBX hangs up a call from the the call-generator FreePBX. The call is being answered by the 911 call-taker simulation FreePBX. The called side plays a 16 sec audio file to the calling side. The called side then hangs up. You will clearly see the BYE request transmitted from the called FreePBX to the call-generator side FreePBX. The calling FreePBX returns a 200 OK to the BYE request. Then the log records several hangup related events on the calling side, but it doesn’t seem as if the g flag in the Dial Command is triggered. Execution of the calling side dialplan context does not resume on the priority statement immediately following the priority that executes the Dial Command.

I’ve never used pastebin before, so I just created an account (mobrien2 also) and have created a paste with the output to /var/log/asterisk/full.

The name of the public paste is: For PitzKey to help with FreePBX Dial Cmd g flag issue.

I would like to point out (perhaps this will be immediately obvious to you from the log) that I don’t actually have a calling device registered with the call generator FreePBX instance. When the call is answered by the 911 call-taker simulation FreePBX, it seems the call generator FreePBX instance wants to bridge audio to a calling device. I didn’t see anyway to defeat the FreePBX from taking that bridge action. Of course, there is no calling device. I would like to produce all calls without an actual calling device. I believe that’s why a status eventually gets reported in the log of NOANSWER. I presume it is referring to the fact that the bridge action failed to connect a calling device into the call. Not sure about that. Perhaps that is the root of the problem??

I appreciate your time and effort in trying to help me with this issue. Thanks.

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