Im trying to execute a long running code in the hangup handler, but it exits early.
Here is the code:
[sipbutton]
exten => _XX,1,Set(ORIEXT=$[h~~${EXTEN}])
exten => _XX,2,Hangup()
exten => h,1,GotoIf($[${LEN(${ORIEXT})} > 2]?sipbutton,h,2:sipbutton,h,3)
exten => h,2,Goto(sipbutton,${ORIEXT},1)
exten => h,3,NoOp(ORIEXT = ${ORIEXT})
exten => h04,1,GotoIf($[“${DEVICE_STATE(Custom:Service04)}”=“NOT_INUSE”]?sipbutton,h04,2:sipbutton,h,3)
exten => h04,2,Set(DEVICE_STATE(Custom:Service04)=RINGING)
exten => h04,3,Wait(7)
exten => h04,4,Set(DEVICE_STATE(Custom:Service04)=BUSY)
exten => h04,5,Wait(40)
exten => h04,6,Set(DEVICE_STATE(Custom:Service04)=NOT_INUSE)
exten => h04,7,Goto(sipbutton,h,3)
exten => blf04,hint,Custom:Service04
This is connected to a blf button on the phone, which will execute a action, that takes 7 seconds, and then takes 40 seconds to “reload”, or more rightly, fill a water tank that takes 40 seconds to fill (haven’t yet written code for it, but it will be a wget command just before device status is set to RINGING). Of course, I dont want the phone to be in a call during that time, so I want to execute it in the hangup handler.
Problem is that the handler exits, early, so how can I force it to run until its done?
(The if cause in h04,1 is to prevent the button from being pressed while its busy doing its thing or “reloading”)
It looks like this:
-- Executing [04@sipbutton:1] Set("SIP/sip05-00000001", "ORIEXT=h04") in new stack
-- Executing [04@sipbutton:2] Hangup("SIP/sip05-00000001", "") in new stack
== Spawn extension (sipbutton, 04, 2) exited non-zero on ‘SIP/sip05-00000001’
– Executing [h@sipbutton:1] GotoIf(“SIP/sip05-00000001”, “1?sipbutton,h,2:sipbutton,h,3”) in new stack
– Goto (sipbutton,h,2)
– Executing [h@sipbutton:2] Goto(“SIP/sip05-00000001”, “sipbutton,h04,1”) in new stack
– Goto (sipbutton,h04,1)
– Executing [h04@sipbutton:1] GotoIf(“SIP/sip05-00000001”, “1?sipbutton,h04,2:sipbutton,h,3”) in new stack
– Goto (sipbutton,h04,2)
– Executing [h04@sipbutton:2] Set(“SIP/sip05-00000001”, “DEVICE_STATE(Custom:Service04)=RINGING”) in new stack
– Executing [h04@sipbutton:3] Wait(“SIP/sip05-00000001”, “7”) in new stack
== Spawn extension (sipbutton, h04, 3) exited non-zero on ‘SIP/sip05-00000001’
It seems it terminates on the wait command. Any ideas?
Its a local SIP phone, and the call on the BLF button terminates into the asterisk, so it would work for me if I just could hang up the SIP client and then let the asterisk leg of the call be alive somehow.