Is there a PJSIP realtime registration table?


#1

Is there a PJSIP realtime registration table, so that multiple Asterisks can know whether a device is registered centrally? If I have multiple Asterisks that could be doing a Dial out to a device or calling through the queue application, how do they all know if the device is registered?


#2

If configured to do so then it can store the information in a database. Registered contacts are stored in the contacts table.


#3

in ps_contacts? I have configured our PJSIP realtime following this guide: https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime


#4

Yes, in ps_contacts. If the endpoint is behind NAT though they may not be reachable - the NAT may prevent traffic from another server from reaching the endpoint.


#5

I have a device registered through a NAT/SBC and it shows us with “pjsip show endpoints”:

sip05*CLI> pjsip show endpoints

 Endpoint:  <Endpoint/CID.....................................>  <State.....>  <Channels.>
    I/OAuth:  <AuthId/UserName...........................................................>
        Aor:  <Aor............................................>  <MaxContact>
      Contact:  <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
  Transport:  <TransportId........>  <Type>  <cos>  <tos>  <BindAddress..................>
    Channel:  <ChannelId......................................>  <State.....>  <Time.....>
        Exten: <DialedExten...........>  CLCID: <ConnectedLineCID.......>
==========================================================================================

 Endpoint:  device_id                                              Not in use    0 of inf
     InAuth:  device_id/device_id
        Aor:  device_id                                            10
      Contact:  device_id/sip:device_id@[NATs IP address]:5060;transp 791eb651c1 Unknown         nan
  Transport:  transport-udp             udp      0      0  0.0.0.0:5060

But, I do not see it in the ps_contacts table. Where do you configure the registration to get stored in ps_contacts?


#6

In the wiki link you’ve provided the:

contact=realtime,ps_contacts

Line configures contacts to be stored in realtime.


#7

Ok, I had missed that configuration. I have added it now, but now Asterisk is sending a 200 OK to the REGISTER requests, but now when I run “pjsip show endpoints” the endpoint is showing as “Unavailable”, and nothing is stored in the ps_contact table. Seems like this made things worse, but I am not sure why.

I do see that in source directory mysql_config.sql file there is a ps_registrations table. What is this used for? Should I be defining this in extconfig.conf and sorcery.conf?


#8

The ps_registrations table is for outbound registrations if I recall.

You’d need to investigate further, such as seeing if there’s any SQL errors and check if it is doing the appropriate insert.


#9

Yes, I see there are problems with the insert. This is how the mysql_config.sql had me configure the ps_contacts table:

CREATE TABLE ps_contacts (
    id VARCHAR(40) NOT NULL,
    uri VARCHAR(40),
    expiration_time VARCHAR(40),
    qualify_frequency INTEGER,
    UNIQUE (id)
);

But, I see that Asterisk is trying to use a lot more columns that are not defined.

SQL: INSERT INTO ps_contacts (id, via_addr, qualify_timeout, call_id, reg_server, prune_on_boot, path, endpoint, via_port, authenticate_qualify, uri, qualify_frequency, user_agent, expiration_time, outbound_proxy) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

But, I see now that there are a bunch of ALERT TABLE statements later in the mysql_config.sql file. I will rerun through this file and fix the tables.


#10

altering the tables to the complete setup worked. Now calls are not authorizing, but that is beyond the scope of what I opened this post for. Thank you for your help!


#11

Hi,
I am also trying to do the same thing. All register request are forwarded to one asterisk which is storing contact details in database. Now on receiving INVITE, I am selecting asterisk server in round robin fashion. I was hoping other asterisk server could read contact details from database. In my case contact details are getting populated in ps_contacts table, but when making sip call following error is coming
“Everyone is busy/congested at this time (1:0/0/1)
– Auto fallthrough, channel ‘xyz’ status is ‘CHANUNAVAIL’”.

And this error is only coming when the INVITE gets forwarded to asterisk which did not register the device.


#12

That’s not really a use case that anyone has fully flushed out or tweaked things to work with. It may theoretically do so depending on configuration, but at the very least you would need to use UDP and if the other side is behind NAT it may or may not work. I’d suggest instead of reusing this forum post to start a new one with actual details.