Possible incompatibility between ODBC and PJSip

Hello, recently I’m trying to move from sip to PjSip. I’m on a 13.11.2 Asterisk with realtime Postgresql using ODBC, will paste some configs after a short explanation.
To get started with PJSip I configured it statically, without any changes on sorcery.conf or pjsip_wizard.conf, all endpoits direct on pjsip.conf and it worked like a charm. (with a clean asterisk install, without odbc yet)
Then I configured ODBC and enabled res_odbc module, and without even configuring my database tables on sorcery.conf and extconfic.conf all my static endpoints lost their object “aor” and cannot register anymore.
The most strange thing is that if I change “enable => no” in res_odbc.conf they get the “aor” configuration once again and are able to register.

I’m on a Debian GNU/Linux 8.9 (jessie)

I installed asterisk with ./configure --with-pjproject-bundled command and confirmed that all pjsip resources were there while ‘make menuconfig’.

ODBC installed packages and configuration files:

dpkg -l | grep odbc
ii  libodbc1:amd64                     2.3.1-3                            amd64        ODBC library for Unix
ii  odbc-postgresql:amd64              1:10.00.0000-1.pgdg80+1            amd64        ODBC driver for PostgreSQL
ii  odbcinst                           2.3.1-3                            amd64        Helper program for accessing odbc ini files
ii  odbcinst1debian2:amd64             2.3.1-3                            amd64        Support library for accessing odbc ini files
ii  unixodbc                           2.3.1-3                            amd64        Basic ODBC tools
ii  unixodbc-dev                       2.3.1-3                            amd64        ODBC libraries for UNIX (development files)

cat /etc/odbcinst.ini
[PostgreSQL]
Description = ODBC para Postgresql
Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
FileUsage = 1

cat /etc/odbc.ini
[asterisk]
Description = ODBC pro Asterisk
Driver = PostgreSQL
Trace = 1
TraceFile = /tmp/tracepsqlodbc.txt
Database = integrador
Servername = localhost
UserName = root
Password = myPassword
Port = 5432
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =

ODBC connection is just fine:
isql asterisk
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

Asterisk config files involved:

cat /etc/asterisk/res_odbc.conf
[asterisk]
enabled => yes
dsn => asterisk
pre-connect => yes
;username => root
;password => myPassword

cat /etc/asterisk/pjsip.conf
; Basic UDP transport
;
[transport-udp]
type=transport
protocol=udp ;udp,tcp,tls,ws,wss
bind=0.0.0.0

[7000]
type=endpoint
context=internal
disallow=all
allow=ulaw
transport=transport-udp
auth=7000
aors=7000

[7000]
type=auth
auth_type=userpass
password=7000
username=7000

[7000]
type=aor
max_contacts=1

The only error that I’m aware of receiving when enabling res_odbc is this when I start asterisk:

[Out 17 15:11:42] ERROR[4548]: config_options.c:877 aco_set_defaults: Unable to set default for 7000, qualify_timeout=3.0
[Out 17 15:11:42] ERROR[4548]: res_sorcery_config.c:317 sorcery_config_internal_load: Could not create an object of type 'aor' with id '7000' from configuration file 'pjsip.conf'
*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:  <ip/cidr.........................>
    Channel:  <ChannelId......................................>  <State.....>  <Time.....>
        Exten: <DialedExten...........>  CLCID: <ConnectedLineCID.......>
==========================================================================================

 Endpoint:  7000                                                 Unavailable   0 of inf
     InAuth:  7000/7000
  Transport:  transport-udp             udp      0      0  0.0.0.0:5060
*CLI> pjsip show auths

  I/OAuth:  <AuthId/UserName.............................................................>
==========================================================================================

     Auth:  7000/7000
*CLI> pjsip show aors
No objects found.

When I try to register a softphone using endpoint 7000:

[Out 17 16:07:53] WARNING[4971]: res_pjsip_registrar.c:664 find_registrar_aor: AOR '7000' not found for endpoint '7000'

Thats the infos and configs I have in mind to be important now, if someone needs anything else just tell me!

Thanks in advance.

How did you do the schema? Using alembic? Did you also configure sorcery.conf?

Yes, I build the tables using Alembic afterwards, populated it just like https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime, it did found the endpoint and the Auths, but the problem with aor was the same.
My sorcery.conf is this when i’m with odbc enabled:

[res_pjsip]
endpoint=config,pjsip.conf,criteria=type=endpoint
endpoint=realtime,ps_endpoints

auth=config,pjsip.conf,criteria=type=auth
auth=realtime,ps_auths

aor=config,pjsip.conf,criteria=type=aor
aor=realtime,ps_aors

contact=realtime,ps_contacts

[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips

And extconfig.conf:

[settings]

ps_endpoints => odbc,asterisk
ps_auths => odbc,asterisk
ps_aors => odbc,asterisk
ps_domain_aliases => odbc,asterisk
ps_endpoint_id_ips => odbc,asterisk
ps_contacts => odbc,asterisk

It’s possible that we had an issue with Alembic in that version of Asterisk, it’s too old for me to recall.

But can the database interfer in my static endpoint in pjsip.conf? It’s strange that if I set “enabled => no” on “res_odbc.conf” my endpoint gets all the information from aors, and with it is enabled he doesn’t.

I feel like i’m messing with anything in my odbc configuration. I’ve already tried other versions of unixODBC and psql_odbc, but they all gave me the same error :confused:

Also, this is my odbc show all:

 *CLI> odbc show all

ODBC DSN Settings
-----------------

  Name:   asterisk
  DSN:    asterisk
    Last connection attempt: 1969-12-31 21:00:00
    Number of active connections: 1 (out of 1)

I wouldn’t expect it to but I can only comment on the latest version of Asterisk. The version you are referencing is a year old and I can’t recall that far back.

Which version of Asterisk do you recommend me for using in this scenario? PJSip+PostgreSQL ?

I can provide help against the latest version of Asterisk if you encounter problems there.

Alright, I’m installing and configuring a VM with Asterisk 15.0.0, tomorrow I may back here tell you what happened, thanks for now! xD

You could also have used the latest version of 13.

If 15 does not work I’ll try 13.18 then! And if it work I’ll try 13.18 too.

Good morning @jcolp, I’ve just finished configuring my Asterisk 15 server and it hapenned the same error.
Firstly I ran it just with static configs, not using odbc at all, and with the endpoint set on pjsip.conf it does get all the information (endpoint, auth and aor). Then I installed alembic, used it to setup my database tables, checked in “isql”, everything was created sucefully, configured res_odbc, sorcery and extconfig just like https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime, populated my database with it’s examples, killed asterisk and started it again: ploft, AoRs are not being loaded from endpoints.
Here is a screenshot from my asterisk being loaded (with verbose off) and an “pjsip show endpoints” command.
http://prntscr.com/gyw9pc.
Help

What is the value of qualify_timeout in the database and what is the column set as? Do you have any data in the database? Please provide this complete information on an issue[1] as it seems as though there is an issue, potentially with the schema.

[1] https://issues.asterisk.org/jira

1 Like

OMG, Just found a solution (don’t know if thats the best, but worked).
I tried to set the value of “qualify_timeout” in pjsip.conf, in pjsip_wizard and on the database, but nothing worked. Then I tried to change the variable type in the “ps_aors” table in database, (it was double precision type), tried to character varying, text, float, real, even integer, but not a single change to the error.
Then I searched in the source files of asterisk where it was trying to set this variable, and changed the variable type to integer, and the value from 3.0 to 3. Kept the database type of qualify_timeout to integer and recompiled asterik, IT WORKED! LOL