Hello Asterisk experts and enthusiasts,
I’m currently having a problem with asterisk that I can’t figure out how to solve: After using chan_sip
for many years without issues I decided to migrate to pjsip
. I’m using Asterisk 17.3.0 on Linux.
After some getting used to (and some more gray hairs) I’ve almost a working setup again. Almost because there is this last problem:
My SIP provider has a nice NAPTR
record that looks like the following (redacted):
phone.provider.example. 4074 IN NAPTR 60 50 "S" "SIP+D2T" "" _sip._tcp.phone.provider.example.
phone.provider.example. 4074 IN NAPTR 50 50 "S" "SIP+D2U" "" _sip._udp.phone.provider.example.
The SRV record for UDP looks like this:
_sip._udp.phone.provider.example. 5452 IN SRV 10 1 5060 phone-a.provider.example.
_sip._udp.phone.provider.example. 5452 IN SRV 10 1 5060 phone-b.provider.example.
And that’s where the problem starts. I’ve got two servers with the same weight. So my asterisk setup is registering my phone numbers (every number needs its own registration) to one of the two servers (redacted and shortened):
[Apr 10 11:50:18] VERBOSE[27575] res_pjsip_logger.c: <--- Transmitting SIP request (870 bytes) to UDP:[XXXX:7::10]:5060 --->
REGISTER sip:phone.provider.example SIP/2.0
Via: SIP/2.0/UDP [XXXX::1]:5060;rport;branch=z9hG4bKPj6a4d2d2b-a2cc-41f3-bfa9-6a35fa81b2a3
From: <sip:+1234567890@phone.provider.example>;tag=bb650b57-ce50-4a18-aff3-150769eb3792
To: <sip:+1234567890@phone.provider.example>
CSeq: 57942 REGISTER
Contact: <sip:+1234567890@[XXXX::1]:5060;line=zzpjnyi>
[Apr 10 11:50:18] VERBOSE[5364] res_pjsip_logger.c: <--- Received SIP response (521 bytes) from UDP:[XXXX:7::10]:5060 --->
SIP/2.0 200 OK
CSeq: 14789 REGISTER
From: <sip:+499118109600@phone.provider.example>;tag=9910ad30-e188-4393-9717-41bddcb390fd
To: <sip:+499118109600@phone.provider.example>;tag=sip+6+a41c0014+8bcbaf4f
Via: SIP/2.0/UDP [XXXX::1]:5060;received=XXXX::1;rport=5060;branch=z9hG4bKPjb11a4c90-694c-49da-bb22-4afc86b15d9b
Contact: <sip:+499118109600@[XXXX::1]:5060;line=wkuwevp>;Expires=1200
After some time a qualify OPTIONS
request is send. Mostly it hits the same IP address as the registration was send to. But sometimes it is send to the second IP address (XXXX:8::10 not XXXX:7::10):
[Apr 10 12:14:36] VERBOSE[28695] res_pjsip_logger.c: <--- Transmitting SIP request (500 bytes) to UDP:[XXXX:8::10]:5060 --->
OPTIONS sip:+1234567890@phone.provider.example;user=phone SIP/2.0
Via: SIP/2.0/UDP [XXXX::1]:5060;rport;branch=z9hG4bKPj22a438fd-440b-4f7c-95c5-6de4ef865505
From: <sip:+1234567890@phone.provider.example>;tag=d8d25981-06c7-471c-9fa3-bd226128ded4
To: <sip:+1234567890@phone.provider.example>
Contact: <sip:+1234567890@[XXXX::1]:5060>
CSeq: 17677 OPTIONS
[Apr 10 12:14:36] VERBOSE[28231] res_pjsip_logger.c: <--- Received SIP response (537 bytes) from UDP:[XXXX:8::10]:5060 --->
SIP/2.0 403 Forbidden
Call-ID: e7afd196-19dc-4f15-8c81-46f91f0acdfd
CSeq: 17677 OPTIONS
From: <sip:+1234567890@phone.provider.example>;tag=d8d25981-06c7-471c-9fa3-bd226128ded4
To: <sip:+1234567890@phone.provider.example>;tag=sip+2+1556000d+4ed19625
Via: SIP/2.0/UDP [XXXX::1]:5060;received=XXXX::1;rport=5060;branch=z9hG4bKPj22a438fd-440b-4f7c-95c5-6de4ef865505
Contact: <sip:+1234567890@[XXXX::1]:5060>
In this case, the SIP server sends a 403 Forbidden
back. If that happens with a REGISTER
SIP message (re-registration) the registration is done on a different server. This leads to all calls currently active on the re-registered SIP-Address on the old server being terminated.
The calling or called parties think I’m rude and hung up on them
Does someone know a solution to force pjsip
to stick to one server after registering to it?
Thank you in advance for any hint or help on this topic.