PJSIP Not Failing Over to Next SRV Target on SIP Timeout or Unreachable Server

V
vishal.maheshwari
Thu, Jun 26, 2025 11:31 AM

Hi,

Please provide resolution for the following :

I'm working with PJSUA/PJSIP (version 2.13) on an embedded Linux setup using DNS SRV
records to register with SIP servers.

My SRV setup points to multiple SIP servers like this (via dnsmasq):

_srv._udp.sip.mylan.internal. 10 60 5060 sip1.mylan.internal.
_srv._udp.sip.mylan.internal. 20 40 5060 sip2.mylan.internal.
_srv._udp.sip.mylan.internal. 20 60 5060 sip3.mylan.internal.

These resolve to IPs like:

  • sip1.mylan.internal ��� 192.xx.x.xx
  • sip2.mylan.internal ��� 192.xx.x.xx
  • sip3.mylan.internal ��� 192.xx.x.xxx

PJSIP does perform the SRV query, resolves A records properly, and sends the first
REGISTER to the server selected by SRV priority + weight.

However, when the selected SIP server is unreachable or SIP stack is down (408
timeout)
, PJSIP does NOT automatically switch to the next available SRV target.

I understand that per RFC 2782 and pj_dns_srv_resolve() documentation, PJSIP is supposed
to return multiple targets, allowing for failover. But in practice, it:

  • Always tries only the first resolved IP
  • Fails with SIP 408 or no response
  • Then just schedules retry with the same server
  • It does not automatically try sip2/sip3 unless I restart or intervene in app logic

My Questions:

  1. Does PJSIP internally support automatic failover between SRV targets when SIP
    REGISTER or INVITE fails due to 408 timeout, 503, or socket-level unreachable
    server
    ?
  2. If not, is the expected approach to handle this manually from on_reg_state() or
    transport callbacks?
  3. What is the best practice to:
  • Track the entire SRV list
  • Check server reachability
  • Force failover programmatically

I���ve reviewed pj_dns_srv_resolve() and know it returns multiple targets in priority
order ��� but I don���t see any retry or switching unless I implement it manually.

Any guidance, examples, or pointers would be very helpful.

Best regards,
Vishal Maheshwari

Scientist 'E',
PQC Team,
TSOC & PQC Group,
CDOT Delhi

Hi, Please provide resolution for the following : I'm working with PJSUA/PJSIP (version 2.13) on an embedded Linux setup using DNS SRV records to register with SIP servers. My SRV setup points to multiple SIP servers like this (via dnsmasq): _srv._udp.sip.mylan.internal. 10 60 5060 sip1.mylan.internal. _srv._udp.sip.mylan.internal. 20 40 5060 sip2.mylan.internal. _srv._udp.sip.mylan.internal. 20 60 5060 sip3.mylan.internal. These resolve to IPs like: - sip1.mylan.internal ��� 192.xx.x.xx - sip2.mylan.internal ��� 192.xx.x.xx - sip3.mylan.internal ��� 192.xx.x.xxx PJSIP does perform the SRV query, resolves A records properly, and sends the first REGISTER to the server selected by SRV priority + weight. However, when the selected SIP server is **unreachable** or **SIP stack is down (408 timeout)**, **PJSIP does NOT automatically switch to the next available SRV target**. I understand that per RFC 2782 and pj_dns_srv_resolve() documentation, PJSIP is supposed to return multiple targets, allowing for failover. But in practice, it: - Always tries only the first resolved IP - Fails with SIP 408 or no response - Then just schedules retry with the same server - It does not automatically try sip2/sip3 unless I restart or intervene in app logic ### My Questions: 1. Does PJSIP internally support automatic failover between SRV targets when SIP REGISTER or INVITE fails due to **408 timeout**, **503**, or **socket-level unreachable server**? 2. If not, is the expected approach to handle this manually from `on_reg_state()` or transport callbacks? 3. What is the best practice to: - Track the entire SRV list - Check server reachability - Force failover programmatically I���ve reviewed `pj_dns_srv_resolve()` and know it returns multiple targets in priority order ��� but I don���t see any retry or switching unless I implement it manually. Any guidance, examples, or pointers would be very helpful. Best regards, Vishal Maheshwari Scientist 'E', PQC Team, TSOC & PQC Group, CDOT Delhi