Asterisk 16.4 pjsip trunk registration

I’m not an asterisk expert, and I’m stuck at this moment.

I’m trying to setup an asterisk box with realtime. Most work, and my endpoints are able to make calls between each other. But I need to setup a SIP trunk to a VOIP provider, and I’m not sure how to do it, because what I’ve done does not work.

The first problem is that my registration does not load. From what I understood the sorcery.conf file needs to be setup for the different objects. I determined that the type basically maps to the type in pjsip.conf, So I’ve setup the information in there. Like I said, the aors, endpoint and auth of my trunk reflects and is loaded, but I can’t seem to get the registration.

I’ve tried setting up the registration (and identity) in pjsip.conf, as well as in the mysql db, but when i run pjsip show registrations, no objects are found. I thought that maybe it is because sorcery.conf does not map the table, but when I add registration=realtime,ps_registrations to the sorcery.conf, pjsip does not start at all

This is my current sorcery.conf setup. I’ve included the commented lines for incase






I have same settings in pjsip.conf as well

server_uri=sip:<ip address of provider>
client_uri=sip:<number>@<ip address of provider>

Endpoint mtntrunk does show when I run commands pjsip show endpoints

If there is more info that you want please ask.

Is there something that I missing? Is my configuration incorrect? Should I configure config file as well as realtime config to make this work?

What’s your extconfig.conf look like? Should have a line similar to the following in it:

ps_registrations => odbc,asterisk

Also, with “registration” enabled/uncommented in your sorcery.conf startup Asterisk and post the startup log (should see some kind of error).

Hi Kharwell

Thanks for the reply.

Ok, I managed to get a little further this morning. Yesteday I saw a post where somebody added a section in sorcery for registrations


This allowed at least for me to get the registrations there with your help of the line in extconfig.conf I had to add. My Transports also loads now (which is awesome), but the identity block does not load.
I’ve added this block in pjconf.conf


and I added this line in sorcery.conf under [res_pjsip_outbound_registration]


but I still don’t see anything in pjsip show identifies
Also the registration fails with the message

res_pjsip_outbound_registration.c: 403 Forbidden fatal response received from 'sip:' on registration attempt to 'sip:0511012138@', retrying in '600' seconds

This is probably just a config thing, so I am busy already with the provider.

I aslo get a SSL error for some reason. It is on a self signed certificate, so I’m not sure if I should be worried at this point. This happens when users connect and make calls with WebRTC.

[Jul  2 07:28:57] ERROR[2446]: iostream.c:633 ast_iostream_start_tls: Problem setting up ssl connection: error:00000001:lib(0):func(0):reason(1), Internal SSL error
[Jul  2 07:28:57] ERROR[2446]: iostream.c:538 ast_iostream_close: SSL_shutdown() failed: error:00000001:lib(0):func(0):reason(1), Internal SSL error

But users are able to connect, and they can call each other.

Sorry, my bad. identify have to be somewhere else, I removed


under [res_pjsip_outbound_registration] because It is supposed to be under [res_pjsip_endpoint_identifier_ip] and It was already there reading realtime, so I’ve added the entry into mysql, and I do have an entry in identifies now. It is only the registration and SSL problem that I still have.

I think I’m almost there. For some reason I can’t get it to register.

The old way seemed to be


or something like that

I have a registrar ip, and I have a username and password and a phone number that is connected to all this. I’ve inserted everything into the tables like this

insert into ps_aors (id, contact, max_contacts) values ('mtntrunk', 'sip:<phonenumber>@<ipaddress>', 1);

insert into ps_endpoints (id, transport, aors, outbound_auth, context, disallow, allow) 
values ('mtntrunk', 'transport-udp', 'mtntrunk', 'mtntrunk-auth', 'default', 'all', 'gsm,ulaw,alaw');

insert into ps_auths (id, auth_type, usename, password, realm) values ('mtntrunk-auth', 'userpass', 
'username', 'password', '3CXPhoneSystem');

insert into ps_registrations (id, transport, outbound_auth,forbidden_retry_interval,line,endpoint)
values ('mtntrunk', 'transport-udp','mtntrunk-auth', '600','yes','mtntrunk');
insert into ps_endpoint_id_ips (id, endpoint, `match`) values ('mtntrunk', 'mtntrunk', 

Should I add a contact_user to ps_registrations and if I do, should I add a ps_contacts as well?
If so, what should I add in there. Currently I have this

insert ps_contacts (id, uri, endpoint,reg_server) values ('mtnuser', 'V4d1xBoBUQ@dYlthJ6tA8:', 'mtntrunk', '');

I currently get a error unknown user on the registration request.

Fatal response '404' received from 'sip:' on registration attempt to 'sip:0511012138@', stopping outbound registration

Wireshark: SIP/2.0 404 User unknown.

Seems like your outbound registration is getting sent, but rejected from the remote. Are you sure the password is correct? This page might be helpful too as it has some stuff about setup and troubleshooting:

Also post a SIP trace and log of the outbound registration. Maybe someone will be able to see something in it.

Oh one other thing. While you can use the same auth section multiple times, it is not advised to use the same one for both inbound and outbound auth. So I would suggest creating another auth record for outbound instead of sharing them. From the help about the “realm” setting:

The treatment of this value depends upon how the authentication object is used. When used as an inbound authentication object, the realm is sent as part of the challenge so the peer can know which key to use when responding. An empty value will use the section’s ‘default_realm’ value when issuing a challenge. When used as an outbound authentication object, the realm is matched with the received challenge realm to determine which authentication object to use when responding to the challenge. An empty value matches any challenging realm when determining which authentication object matches a received challenge.
NOTE: Using the same auth section for inbound and outbound authentication is not recommended. There is a difference in meaning for an empty realm setting
between inbound and outbound authentication uses.

Hi kharwell,

Ok, the authentication on the sip line is sorted out now, and asterisk registers the line, however I still have a funny anomaly.

I used the pjsip_wizard to configure the line. This is my config

type = wizard
sends_auth = yes
sends_registrations = yes
accepts_registrations = no
remote_hosts =
outbound_auth/username = 4200
outbound_auth/password = -deleted-
endpoint/context = default
aor/qualify_frequency = 15

I also downloaded x-lite sip phone to test this line. It all works. I’ve used the IP as the Domain, and I can make calls etc.
Asterisk however give me some issues. It registers and it works. From wireshark some things looks a little different between the Softphone and Asterisk. The softphone does a subscribe as well which asterisk does not do.
Also when I try to make a call, it rejects me.

This is my extensions.conf section for it.

exten => _XXX.,1,NoOp()
same => n,Set(CALLERID(num)=4002)
same => n,Dial(PJSIP/${EXTEN}@mtntrunk,25)
same => n,Hangup()

This is the log
== Setting global variable ‘SIPDOMAIN’ to ‘’
– Executing [27658733246@default:1] NoOp(“PJSIP/CollectIQUser1-00000000”, “”) in new stack
– Executing [27658733246@default:2] Set(“PJSIP/CollectIQUser1-00000000”, “CALLERID(num)=4002”) in new stack
– Executing [27658733246@default:3] Dial(“PJSIP/CollectIQUser1-00000000”, “PJSIP/27658733246@mtntrunk,25”) in new stack
– Called PJSIP/27658733246@mtntrunk
== Everyone is busy/congested at this time (1:0/0/1)
– Executing [27658733246@default:4] Hangup(“PJSIP/CollectIQUser1-00000000”, “”) in new stack
== Spawn extension (default, 27658733246, 4) exited non-zero on ‘PJSIP/CollectIQUser1-00000000’

On wireshark, it does the invite, the server challenge again with authentication, and then I get a user unknown back. The only difference that I can see in wireshark is the Contact that is different.
On asterisk it is sip:asterisk@, and on the softphone it is sip:4200@;rinstance=70b06afaee70c2fe, and I’m not sure how to change that on asterisk not to have the asterisk prefix, but 4200.

Try setting the contact_user option on the endpoint:

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