SIP Trunk Registration Issue – Extension Offline

Hello,

I have an issue with one of my SIP trunks in chan_pjsip.

This problem only occurs with this particular SIP registrar. When I use pjsip show registrations, the trunk is marked as registered, but on the SIP registrar’s side, the extension is marked as “offline”, preventing incoming calls. The provider says the following:

10.4. OPTIONS Packets

To check the online status of the phone system, the server sends OPTIONS packets at regular intervals. These must be answered with a 200 OK message; otherwise, the system is considered offline, and calls will not be routed.

Trunking: OPTIONS Packets

11. DNS SRV

The resolution of the domain name sip.example.com and the proxy server proxyXX.sip.example.com is performed through an SRV Resource Record. In both cases, a list of call servers is returned.

The UDP SRV lookup for sip.example.com contains an unprioritized list of 18 call servers, so it must fall back to TCP. When looking up the proxy server, only 3 prioritized call servers are returned. This variant is preferable. Without using DNS SRV lookup, registration, call setup, and call routing will fail.

Example:

; <<>> DiG 9.8.2-P1 <<>> srv_sip._udp.proxy01.sip.example.com
[…]

;; ANSWER SECTION:
_sip._udp.proxy01.sip.example.com. 7782 IN SRV 3 10 5060 voice12.sip.example.com.
_sip._udp.proxy01.sip.example.com. 7782 IN SRV 1 10 5060 voice09.sip.example.com.
_sip._udp.proxy01.sip.example.com. 7782 IN SRV 1 10 5060 voice06.sip.example.com.

My current pjsip.conf looks like this:

[mytrunk]
type=registration
transport=udp
outbound_auth=mytrunk_auth
server_uri=sip:sip.example.com
client_uri=sip:myusername@sip.example.co
retry_interval=60
max_retries=100
line=yes
endpoint=mytrunk_endpoint

[mytrunk_auth]
type=auth
auth_type=userpass
username=myusername
password=mypassword

[mytrunk_aor]
type=aor
contact=sip:myusername@sip.example.com
qualify_frequency=15

[mytrunk_endpoint]
type=endpoint
transport=udp
context=mycontext
disallow=all
allow=alaw
direct_media=no
from_user=myusername
from_domain=sip.example.com
outbound_auth=mytrunk_auth
aors=mytrunk_aor

As long as the issue is not resolved, incoming calls cannot be received.

Thanks for your help.

Yours sincerely

You need to define an extension that matches the request URI in the OPTIONS request. To get an OK, the OPTIONS must be sent to a completely valid address, as the condition for an OK is that an INVITE, to the same address, would succeed.

If they are sending just a domain name (no user part) you should use extension s.

If you haven’t set a contact user, but expect them to send a phone number, in INVITEs, you need to set contact user to that phone number.

Sensible systems accept that any response means there is valid connectivity, and don’t insist on a 200 response.

(I think there are some options that relate to 200 and OPTIONS, but I can’t remember if they result in 200 being sent instead of 404, or whether they require a 200 response to outbound OPTIONS.)

I’m assuming the DNS SRV section refers to outbound requests, but don’t understand the use of example.com. I wouldn’t expect many users of ITSPs use DNS SRV, and redacting a provider address, when asking for support here, is counterproductive, as it means responders cannot use their knowledge of that provider, or look up their documentation individually.

Hi David,

thank for your quick response! :heart:

Since I started using exten => s,1,Answer() in extensions.conf it works. Can you explain why the ,s is necessary? All of my previous SIP registrars accept _X. or _+X. .

You said

If they are sending just a domain name (no user part) you should use extension s.

What’s the difference between

,s

and

_X.

?

s matches a literal “s”, or an omitted user part. (sip:s@xxx.xxx.xxx.xxx, or sip:xxx.xxx.xxx.xxx)
.
_X. matches a decimal digit followed by, at least, one other character.

(e.g. sip:15555551234@xxx.xxx.xxx.xxx, sip:2A@xxx.xxx.xxx.xxx).

The most likely reason is that the the other registrar either didn’t test connectivity, did, as Asterisk itself does, accept any well formed response as confirming connectivity, so didn’t mind that it got a 404 (number not found) response.

A secondary possibility is that the others ignored the user part in the Contact header, in the registration, and replaced it with a number configured for your account, although I think that is a lot less likely.

1 Like

Ok. The provider only provides a guide for sip.conf on their website, but no guide for chan_pjsip. Thank you, I am very grateful for your helpful response, as my trunk is now reliably reachable again. Previously, I had ‘s’ in the extension and changed it to ‘_X.’, which caused the registration to be interrupted, and I didn’t know that it was due to the dialplan. Very confusing!

Have a nice day David!

I have one more question, even though it’s off-topic. Can you tell me why the provider sends a ringback tone before the call reaches my PBX? Is it due to the provider, or do I need to enable some sort of early-media in pjsip.conf?

It doesn’t seem very well-handled when the provider sends a ringback tone and Asterisk then sends a busy signal one second later, or when the provider sends a ringback tone and after one second, the MOH of my queue is played.

If there’s ringback before it even gets to Asterisk, then that would be the provider and you’d need to ask them most likely.

1 Like