PJSIP with realtime get ipaddr populated

I have been using sip with realtime odbc, to be more specific sippeers table.

Now I am studying to move to pjsip, I already had success to make pjsip work with ps_ tables with odbc, but I am missing a important feature that is on sippeers.

When I register a sip peer the column ipaddr, port, useragent and others are updated automatically.

 id | name |   ipaddr   | port  | regseconds |   defaultuser   |          fullcontact           | regserver |    useragent    | lastms
----+------+------------+-------+------------+-----------------+--------------------------------+-----------+-----------------+--------
  1 | 2000 | 10.120.0.6 | 58329 | 1667586209 | SIP Celso Annes | sip:2000@10.120.0.6:58329^3Bob |           | MicroSIP/3.21.2 |     13

I follow this instructions: Setting up PJSIP Realtime - Asterisk Project - Asterisk Project Wiki

I didn’t find any way to make it work on the ps_ tables, is really important to me when a peer register its ip be registered on the table so I can easily read his informations.

Is there a way when using pjsip with realtime tables, Asterisk be abble to automatically populate the ps_ tables with peer’s IP?

Like what happens when using sipppers table and asterisk populate the ip in the peer’s table row.

Thanks.

Contacts get added to the table that holds them which contain information on how to contact a device. The endpoint is not updated.

Sorry, I could not understand what you try to explain to me.

When you say Contacts, are you talking about the table ps_contacts? Because this one is not getting populate when I register a pjsip.

pjsip*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..................>
   Identify:  <Identify/Endpoint.........................................................>
        Match:  <criteria.........................>
    Channel:  <ChannelId......................................>  <State.....>  <Time.....>
        Exten: <DialedExten...........>  CLCID: <ConnectedLineCID.......>
==========================================================================================

 Endpoint:  101                                                  Not in use    0 of inf
     InAuth:  101/101
        Aor:  101                                                1
      Contact:  101/sip:101@10.120.0.6                     8d4aed5729 NonQual         nan
  Transport:  transport-udp             udp      0    104  0.0.0.0:5060

 Endpoint:  102                                                  Not in use    0 of inf
     InAuth:  102/102
        Aor:  102                                                1
      Contact:  102/sip:79254803@10.120.0.6:51240          a3ff8712ec NonQual         nan
  Transport:  transport-udp             udp      0    104  0.0.0.0:5060


Objects found: 2

Table: ps_contacts

anequim_config=# SELECT * FROM public.ps_contacts;
 id | uri | expiration_time | qualify_frequency | outbound_proxy | path | user_agent | qualify_timeout | reg_server | authenticate_qualify | via_addr | via_port | call_id | endpoint | prune_on_boot
----+-----+-----------------+-------------------+----------------+------+------------+-----------------+------------+----------------------+----------+----------+---------+----------+---------------
(0 registro)

That is indeed the table, and you haven’t actually shown configuration of things showing that the table should be used - so it is entirely possible that it is not, and the information is being stored in the local astdb instead.

Ok, I find the problem, you were right.

On my first try to make pjsip work for some reason I had to comment contact=realtime,ps_contacts on sorcery.conf, this line wasn’t let the peers get registered, so when I commented it, I could make peers get registered, and never look back.

The problem was some misconfiguration on sorcery.conf or extconfig.conf that I probably get correct on the way and didn’t realize.

I based my thinking on the wiki, like was wrote: “PJSIP bases its configuration on types of objects” (endpoint, auth, aor, domain, identify) and PJSIP only “worked” when contact was commented I thought it wasn’t important.

Thanks for the help!

My sorcery.conf

[res_pjsip]
endpoint=realtime,ps_endpoints
auth=realtime,ps_auths
aor=realtime,ps_aors
domain_alias=realtime,ps_domain_aliases
contact=realtime,ps_contacts


[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips


[res_pjsip_outbound_publish]
outbound-publish=realtime,ps_outbound_publishes


[res_pjsip_pubsub]
inbound-publication=realtime,ps_inbound_publications


[res_pjsip_publish_asterisk]
asterisk-publication=realtime,ps_asterisk_publications

My extconfig.conf

[settings]
sippeers => odbc,anequim_config
extensions => odbc,anequim_config
psql_hints.conf => odbc,anequim_config,psql_hints_conf
psql_stdexten.conf => odbc,anequim_config,psql_stdexten_conf
users.conf => odbc,anequim_config,users_conf
confbridge.conf => odbc,anequim_config,confbridge
queue_log => odbc,anequim_cdr,queue_log
queues => odbc,anequim_config
queue_members => odbc,anequim_config
musiconhold => odbc,anequim_config
voicemail => odbc,anequim_config
extensions_queues.conf => odbc,anequim_config,extensions_queues_conf

;PJSIP
ps_endpoints => odbc,anequim_config
ps_auths => odbc,anequim_config
ps_aors => odbc,anequim_config
ps_domain_aliases => odbc,anequim_config
ps_endpoint_id_ips => odbc,anequim_config
ps_outbound_publishes => odbc,anequim_config
ps_inbound_publications = odbc,anequim_config
ps_asterisk_publications = odbc,anequim_config
ps_contacts = odbc,anequim_config

Table: ps_contacts now:

anequim_config=# SELECT * FROM public.ps_contacts;
                   id                    |        uri         | expiration_time | qualify_frequency | outbound_proxy | path |   user_agent    | qualify_timeout | reg_server | authenticate_qualify |  via_addr  | via_port |                     call_id                     | endpoint | prune_on_boot
-----------------------------------------+--------------------+-----------------+-------------------+----------------+------+-----------------+-----------------+------------+----------------------+------------+----------+-------------------------------------------------+----------+---------------
 101^3B@8d4aed5729490ec826d669283fe03648 | sip:101@10.120.0.6 |      1669050921 |                 0 |                |      | PhonerLite/2.99 |               3 |            | yes                  | 10.120.0.6 |     5060 | 8020521E-2968-ED11-851E-D9D9900B01D1@10.120.0.6 | 101      | no
(1 registro)