How does several "remote_hosts" are handled in a SIP Trunk?

I’m using the pjsip wizard in Asterisk 18 and when I define a SIP Trunk, there is now the ability to set several distant endpoint in “remote_hosts”:

trunk-defaults
type = wizard
transport = transport-tcp ; Explicit transport configuration to use
endpoint/allow = !all,ulaw,alaw ; Media Codec(s) to allow
endpoint/context = incoming ; Dialplan context to use
endpoint/dtmf_mode = auto ; DTMF is sent as RFC 4733 if the other side supports it or as INBAND if not.
endpoint/direct_media = yes ; Enable direct media (peer to peer RTP)
;endpoint/tos_audio = ef ; Sets TOS for audio streams (QoS)
;endpoint/cos_audio = 5 ; Sets COS for audio streams (QoS)
aor/qualify_frequency = 30 ; Interval at which to qualify an AoR (SIP Options Ping)

TRUNK
remote_hosts = 10.157.7.4:5060,10.157.7.6:5060
identify/match = 10.157.7.4,10.157.7.6

This is great as it allows to have resiliency defined directly in the SIP Trunk definition.

However I could not find information about how the resiliency itself is implemented…or how to adapt/change it:

  • Load Balancing VS Priority of the listing?
  • Failover permanent VS automatic FallBack?

Are there specific settings for this?

Thanks

G.

There is no load balancing or configuration for it. If qualify is enabled, then each would be tested and if any became unreachable they would not be used. I believe the order given should be used, but that’s not ultimately guaranteed and is more a property of the implementation itself.

Hi,

Thanks for your answer (apologies for the long delay in feedback from my end)

What do you mean by “is more a property of the implementation itself”?
Where in the implementation can I control the order?

In my routing, I’m sending the call to the TRUNK:

  • exten => _X.,16,Dial(PJSIP/+33${EXTEN:1}@TRUNK,300)
    but I don’t have control over to which hosts.

Ultimately, I would like to always send it to the First remote host, unless it is not available.

Thanks

The implementation is in code, with the way contacts are managed and retrieved. If you require explicit management over ordering then you’d need to use multiple and manage it in dialplan when calling.