How to use register in pjsip

I got about 70% of my sip.conf working in pjsip, but this incoming line that uses registration, escapes me.

Thanks in advance for anyone who might give me some direction.

This is what was in sip.conf:

;register => 6xxxxxxxx9:PassWord@2way.ipcomms.net/6xxxxxxxx9

;[6xxxxxxxx9]
;type=friend
;secret=PassWord
;defaultuser=6xxxxxxxx9
;fromuser=6xxxxxxxx9
;bindport=5060
;port=5060
;fromdomain=64.154.41.158
;host=64.154.41.158
;context=ipcomms
;disallow=all
;allow=ulaw
;dtmfmode=auto
;qualify=55000
;canreinvite=no

And this is what I’ve tried in pjsip.conf. sip.conf works perfect, pjsip not so much. What’s in the uri lines in the registration section is just the latest attempt.

[simpletrans]
type=transport
protocol=udp
bind=0.0.0.0
local_net=192.168.233.0/24
local_net=192.168.211.0/24
external_media_address=myip.no-ip.biz
external_signaling_address=myip.no-ip.biz

[6xxxxxxxx9]
type=endpoint
transport=simpletrans
context=ipcomms
allow=!all,ulaw
outbound_auth=6xxxxxxxx9-auth
aors=6xxxxxxxx9

[6xxxxxxxx9-auth]
type=auth
auth_type=userpass
password=PassWord
username=UsersName


[6xxxxxxxx9]
type=registration
outbound_auth=6xxxxxxxx9-auth
server_uri=sip:64.154.41.158
client_uri=6xxxxxxxx9:PassWord@64.154.41.158/6xxxxxxxx9

[6xxxxxxxx9]
type=aor
max_contacts=1

[6xxxxxxxx9]
type=identify
endpoint=6xxxxxxxx9
match=64.154.41.158

Delete :PassWord and /6xxxxxxxx9 from the client URI

Add outbound_auth to the type=registration section.

Add contact_user to the that section.

Replace max_contacts by contact=sip:64.154.41.158

If your sip.conf really works without using either remotesecret or insecure=invite, add auth to your endpoint. It is extremely unusual for a provider to authenticate itself, but, if they prepared to do so, you might as well challenge them.

Then correct your sip.conf:

Delete defaultuser (not useful without defaultdomain and host=dynamic)

Change type to peer (cause an unnecessary reduction in security)

Change canreinvite to directmedia (name has been deprecated, probably for over a decade)

Thanks so much. So I made the changes and it worked for awhile. Then I restarted Asterisk and then it didn’t work again.

This was already in the registration section, wasn’t it?

Add outbound_auth to the type=registration section.

I probably wrote this line over a decade ago, I think I started with V1.4:

Change canreinvite to directmedia (name has been deprecated, probably for over a decade)

So, now it looks like this and still doesn’t work:

[6xxxxxxxx9]
type=endpoint
transport=simpletrans
context=ipcomms
disallow=all
allow=ulaw
;allow=!all,ulaw
outbound_auth=6xxxxxxxx9-auth
aors=6xxxxxxxx9

[6xxxxxxxx9-auth]
type=auth
auth_type=userpass
password=PassWord
username=6xxxxxxxx9

[6xxxxxxxx9]
type=registration
outbound_auth=6xxxxxxxx9-auth
server_uri=sip:2way.ipcomms.net
client_uri=6xxxxxxxx9@sip:2way.ipcomms.net

[6xxxxxxxx9]
type=aor
contact=sip:2way.ipcomms.net

[6xxxxxxxx9]
type=identify
endpoint=6xxxxxxxx9
match=2way.ipcomms.net

What does “doesn’t work” mean? What actually happens?

That’s an incoming only line and I get busy when I call it and there is no indication on the console that asterisk saw any notification of the call. Seems like what would happen if it didn’t register at all.

Does “pjsip show registrations” show anything and if so what is the status? Are there any warning messages at startup?

I will check this tonight when I can shut down the system. Thanks so much for answering.

[2023-08-29 19:29:35] ERROR[53633] config_options.c: Could not find option suitable for category '6314098389' named 'auth' at line 116 of [2023-08-29 19:29:35] ERROR[53633] res_sorcery_config.c: Could not create an object of type 'registration' with id '6314098389' from configuration file 'pjsip.conf'
and pjsip show registrations says no objects found.

Right, because the option is named “outbound_auth” and not “auth”. The configuration is invalid, and seemingly doesn’t match what you provided previously.

Now I’m really confused. David 555 said to do this:

Delete :PassWord and /6xxxxxxxx9 from the client URI

Add outbound_auth to the type=registration section.

Add contact_user to the that section.

Replace max_contacts by contact=sip:64.154.41.158

I did 3 of the things, but outbound auth was already in the registration section. so I left that alone. When I tried changing it to auth it gave an error. Since this is an inbound only line, should it say inbound_auth?

Ira

It should not say “inbound_auth”. According to the error message it was “auth” and not “outbound_auth”. This would prevent the configuration from loading. What is the actual current configuration?

Here is the current configuration:

[code]
[simpletrans]
type=transport
protocol=udp
bind=0.0.0.0
local_net=192.168.233.0/24
local_net=192.168.211.0/24
external_media_address=ezzzzzzzzzzy.no-ip.biz
external_signaling_address=ezzzzzzzzzzy.no-ip.biz

[6xxxxxxxx9]
type=endpoint
transport=simpletrans
context=ipcomms
disallow=all
allow=ulaw
outbound_auth=6xxxxxxxx9-auth
aors=6xxxxxxxx9

[6xxxxxxxx9-auth]
type=auth
auth_type=userpass
password=PzzzzzzzzD
username=6xxxxxxxx9

[6xxxxxxxx9]
type=registration
outbound_auth=6xxxxxxxx9-auth
server_uri=6xxxxxxxx9@ssip:2way.ipcomms.net
client_uri=6xxxxxxxx9@sip:2way.ipcomms.net

[6xxxxxxxx9]
type=aor
contact=sip:2way.ipcomms.net

[6xxxxxxxx9]
type=identify
endpoint=6xxxxxxxx9
match=2way.ipcomms.net

[code/]

And I still have these errors:

[2023-08-29 19:30:39] ERROR[53695] res_pjsip_outbound_registration.c: Client URI or hostname length exceeds pjproject limit or is not a sip(s) uri: '6314098389'

[2023-08-29 19:30:39] ERROR[53695] res_sorcery_config.c: Could not create an object of type 'registration' with id '6314098389' from configuration file 'pjsip.conf'

client_uri=6xxxxxxxx9@sip:2way.ipcomms.net
server_uri=6xxxxxxxx9@ssip:2way.ipcomms.net

should be

client_uri=sip:6xxxxxxxx9@2way.ipcomms.net
server_uri=sip:way.ipcomms.net

I made that change, no change. I though it was that way before and changed it to see if it would help.

Thanks for all the help, turned out to be those lines which needed to look like:

server_uri=sip:2way.ipcomms.net
client_uri=sip:6xxxxxxxx9@2way.ipcomms.net

And yet I still have problems, if I restart Asterisk this works for a minute or two and then stops receiving calls. I added retry_interval=60 with the hope the connection just needed to be kept alive, but that doesn’t seem to have helped. any suggestions

You need to provide pjsip set logger on type logs. Unless those logs show Asterisk unregistering, the problem lies outside Asterisk.

It’s odd, it’s been working fine for 12 years using SIP and with PJSIP it’s suddenly a problem. Any particular PJSIP debug commands I should use. I cant find documentation. What I see or I guess don’t see after setting debug on is any registration attempts by Asterisk. Should it not do something ever retry_interval seconds if I put that in the type=registration section?

So it seems like adding these three lines allowed it to work properly.

retry_interval=60
transport=simpletrans
expiration=90

Since I see no reason to make t he expiration shorter that necessary I will extend it till it stops working. in sip.conf I had qualify=5500, though I don’t know how or if qualify and expiration are related.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.