PJSIP: 2 wan same isp sip provider

Hi,
i’m new in this community, i’ve a trouble with a inbound configuration with pjsip.

I’ve the same pjsip trunk registration over 2 wan (for a failover dls isp) .
All works ok with outbound call but with inbound i’ve a problem :

  • when isp provides are online incoming call is ok
  • when the second wan is going down it’s all ok
  • when the first wan is going down incoming call doesn’t work

The problem is the the match variable inside pjsip.identity configuration :

[isp_wan1]
type=identify
endpoint=isp_wan1
match=same_sip_provider

[isp_wan2]
type=identify
endpoint=isp_wan2
match=same_sip_provider

More debugging i see that module res_pjsip_endpoint_identifier_ip.so match only the first occurence without see the endpoint registration status ( i think if endpoint registration status is down go to second occurence ).

Module res_pjsip_endpoint_identifier_user.so it’s it’s inusable , take only the From header of invite.
In invite there is one another string on the fist line :

INVITE sip:isp_wan1@myip:5061 SIP/2.0

There is a solution to use INVITE sip uri header instead from sip uri header ?

The identify section matches on source IP address only without regard to anything else (including endpoint status as it shouldn’t matter). It’s not made to match like how you are needing, none of the endpoint identifiers currently are. You would need to continue to use the IP based matching and parse in the dialplan using PJSIP_HEADER or write your own endpoint identifier.

ok for dialplan PJSIP_HEADER , but the problem is the rtp media server ( identify -> endpoint ).

if on the endpoint configuration i’ve this :
[isp_wan1]
media_address=public_ip_isp_wan1
bind_rtp_to_media_address=yes

[isp_wan2]
media_address=public_ip_isp_wan2
bind_rtp_to_media_address=yes

The call is entering on the endpoint that match identify and use the media_address of endpoint.
If the isp_wan1 on the endpoint is down and the call is entering from isp_wan2 (first match from pjsip match on the identify section isp_wan1 ) , it can’t inizialize the rtp flow between asterisk and the sip provider.

There is a function on dialplan to change the rtp media address? :sweat_smile:

No, there isn’t. Asterisk can’t do exactly what you need with what exists right now.

ok if i wanna rewrite res_pjsip_endpoint_identifier_user.c for matching invite sip uri vs from sip uri is there some kind of guide for dev or is it too nasty thing ? :stuck_out_tongue:
This endpoint identify “plugin” is good for internal user but for trunking is nosense.

There’s no guide or anything. You get a request and then it’s up to you to determine what endpoint it came from. As for trunking - I disagree, just because it’s not useful for exactly what you need doesn’t mean it’s nonsense. The IP based one is in use for ITSP matching for quite a few people. What’s different is that you are doing failover and need to determine not just who it is from - but where it came in on.

Ok thanks for explanation and suggestion.
There is a chance for a future endpoint identify module doing this?
I’m following asterisk from 1.2 release you are doing a great job!

I can’t speak for anyone writing such a thing for your use case, but if one were put up for review it could certainly go in if it passed code review.