Converting SIP to PJSIP , i need DIALSTATUS ? is it changed?

I’m not sure how you want to handle all the different possible SIP responses, but if you only want to redial on a 603, you could do something like this.

exten => 2,1,Dial(PJSIP/6000,45)
same => n,Set(HANGUPCAUSEKEYS=${HANGUPCAUSE_KEYS()})
same => n,GotoIf($[${LEN(${HANGUPCAUSEKEYS})}=0]?logError)
same => n,Set(ARRAY(item)=${HANGUPCAUSEKEYS})
same => n,Set(SIPCAUSE=${HANGUPCAUSE(${item},tech)})
same => n,Set(SIPCAUSECODE=${CUT(SIPCAUSE, ,2)})
same => n,GotoIf($["${SIPCAUSECODE}" != “603”]?callNotDeclined)
same => n,NoOp(Received SIP response 603 Decline. Waiting 3 seconds then redialing…)
same => n,Wait(3)
same => n,Dial(PJSIP/6000,45)
same => n,NoOp(Dialing failed after second attempt. Hanging up…)
same => n,Hangup()
same => n(callNotDeclined),NoOp(Dialing failed with: ${SIPCAUSECODE}. Not retying…)
same => n,Hangup()

The main change I made here is if you are testing “${SIPCAUSECODE}” != “603”, that’s going to be true when the cause code does not equal 603 (because != means not equals). So, if the SIP response is not 603, you would jump to another place in the dialplan and do something else (like hangup maybe). If the SIP response is 603, it would just continue to the next line in your dialplan and retry the Dial.

thnx verry much, this is working!!

i now use it on sip code 404

i have a softphone, with no push/keep alive method
so sometimes it happens, that i cant reach it, so when i know receive a 404 , i send from the dialplan and webhook event to the app on my android to reregister itself , and then it tries again

it works, much appreciated!!

hey @jwilhite , the dialplan is working, allthough i have 1 question, i have set an qualify on my extensions

Seems when the extension is not reachable, it doesnt provide me any HANGUPCAUSEKEYS … see below

is it also possible to tackle this one? I want to retry dial also 1 time when its unreachable

[Apr  3 14:23:45]     -- Executing [s@default:4] Dial("PJSIP/mytrunk-00000021", "PJSIP/6000,45") in new stack
[Apr  3 14:23:45] ERROR[564]: res_pjsip.c:4090 ast_sip_create_dialog_uac: Endpoint '6000': Could not create dialog to invalid URI '6000'.  Is endpoint registered and reachable?
[Apr  3 14:23:45] ERROR[564]: chan_pjsip.c:2657 request: Failed to create outgoing session to endpoint '6000'
[Apr  3 14:23:45] WARNING[737][C-00000012]: app_dial.c:2663 dial_exec_full: Unable to create channel of type 'PJSIP' (cause 3 - No route to destination)
[Apr  3 14:23:45]     -- No devices or endpoints to dial (technology/resource)
[Apr  3 14:23:45]     -- Executing [s@default:5] Set("PJSIP/mytrunk-00000021", "HANGUPCAUSEKEYS=") in new stack
[Apr  3 14:23:45]     -- Executing [s@default:6] GotoIf("PJSIP/mytrunk-00000021", "1?logError") in new stack
[Apr  3 14:23:45] NOTICE[737][C-00000012]: pbx.c:2978 pbx_extension_helper: No such label 'logError' in extension 's' in context 'default'

It can’t provide hangup cause keys, if no SIP status was received. None was received because none was sent. Typically HANGUPCAUSE will be 20, in this case.

but how can i retrieve that “20” value in the dialplan above so, i can do a retry dial ?

${HANGUPCAUSE} gives you internal (ISDN based) code, including the 20, for subscriber absent.

aha, seems the hangup cause is 3 in this case
thnx for this info!

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