[HELP] trunk failover for PJSIP

I have two UDP PJSIP channels (unregistered private trunks) that I am trying to configure failover between. The scenario I’m trying to solve for is loss of data connectivity.

In a very simple configuration:

[from-internal]
exten => _X!,1,Dial(PJSIP/${EXTEN}@endpoint-0,3)
same => n,Dial(PJSIP/${EXTEN}@endpoint-1,120)

My issue is that if I do not configure a timeout for the dial application the call will have dead air for about 30 seconds before it tries the next priority. This is unacceptable for end users as they will not wait that long. If I do set a short timeout calls don’t have enough time to ring/answer.

I’d like to configure UDP timeout for 2 or 3 seconds but have the call (ring/answer) timeout to 120 seconds. Is there a configuration somewhere for UDP timeout?

My original plan was to configure SIP OPTIONS and check the status of the channel before dialing similar to:

However for an unregistered trunk I wasn’t able to find a way to turn on OPTIONS heartbeats in PJSIP and get the status of the trunk within dialplan. Is this fucntionality available in PJSIP similar to chan_sip?

I appreciate any assistance.

There is no such thing as a “UDP timeout”. As for using SIP OPTIONS that is what people do, and you don’t need to check before dialing. The act of dialing will check the status and if the other side is unreachable the dial will immediately fail.