Hello Asterisk Community,
I’m reaching out for assistance regarding a challenge I’ve encountered with my Asterisk setup. I am currently using Asterisk 18.20.2 and have configured it to fetch real-time PJSIP endpoint data from a PostgreSQL database using ODBC, but I’m facing some issues.
Here’s a brief overview of my setup:
- ODBC Configuration: I have set up the ODBC connection to my PostgreSQL database. My
res_odbc.conf
andodbc.ini
files are configured with the necessary details, and the ODBC DSN is named “asterisk-postgresql”. - Asterisk Configuration:
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
res_odbc.conf
[asterisk]
enabled => yes
dsn => asterisk-postgresql
username => asterisk
password => asterisk
pre-connect => yes
sanitysql => select 1
logging => yes
sorcery.conf
[res_pjsip]
endpoint=realtime,ps_endpoints
auth=realtime,ps_auths
aor=realtime,ps_aors
[res_pjsip_endpoint_identifier_ip]
identify=realtime,ps_endpoint_id_ips
[res_pjsip_outbound_publish]
outbound-publish=realtime,ps_outbound_publish
[res_pjsip_pubsub]
inbound-publication=realtime,ps_inbound_publication
[res_pjsip_publish_asterisk]
asterisk-publication=realtime,ps_asterisk_publication
- PostgreSQL Database: The necessary tables for PJSIP settings are created in the database using
cpntrib/realtime/postgresql/postgresql_config.sql
.
Tables populated with data:
insert into ps_aors (id, max_contacts) values (801, 1);
insert into ps_aors (id, max_contacts) values (802, 1);
insert into ps_aors (id, max_contacts) values (803, 1);
insert into ps_aors (id, max_contacts) values (804, 1);
insert into ps_aors (id, max_contacts) values (805, 1);
insert into ps_auths (id, auth_type, password, username) values (801, 'userpass', 'Obelix', 801);
insert into ps_auths (id, auth_type, password, username) values (802, 'userpass', 'Obelix', 802);
insert into ps_auths (id, auth_type, password, username) values (803, 'userpass', 'Obelix', 803);
insert into ps_auths (id, auth_type, password, username) values (804, 'userpass', 'Obelix', 804);
insert into ps_auths (id, auth_type, password, username) values (805, 'userpass', 'Obelix', 805);
insert into ps_endpoints (id, aors, auth, context, allow, direct_media, dtls_auto_generate_cert, media_encryption) values (801, '801', '801', 'call-router', 'ulaw|alaw|g722|gsm|opus', 'no', 'yes', 'sdes');
insert into ps_endpoints (id, aors, auth, context, allow, direct_media, dtls_auto_generate_cert, media_encryption) values (802, '802', '802', 'call-router', 'ulaw|alaw|g722|gsm|opus', 'no', 'yes', 'sdes');
insert into ps_endpoints (id, aors, auth, context, allow, direct_media, dtls_auto_generate_cert, media_encryption) values (803, '803', '803', 'call-router', 'ulaw|alaw|g722|gsm|opus', 'no', 'yes', 'sdes');
insert into ps_endpoints (id, aors, auth, context, allow, direct_media, dtls_auto_generate_cert, media_encryption) values (804, '804', '804', 'call-router', 'ulaw|alaw|g722|gsm|opus', 'no', 'yes', 'sdes');
insert into ps_endpoints (id, aors, auth, context, allow, direct_media, dtls_auto_generate_cert, media_encryption) values (805, '805', '805', 'call-router', 'ulaw|alaw|g722|gsm|opus', 'no', 'yes', 'sdes');
However, when I run pjsip show endpoints
in the Asterisk CLI, I receive a “No objects found” message, despite having PJSIP endpoint data in the PostgreSQL database:
> odbc show all
ODBC DSN Settings
-----------------
Name: asterisk
DSN: asterisk-postgresql
Number of active connections: 1 (out of 1)
Logging: Enabled
Number of prepares executed: 0
Number of queries executed: 0
I have double-checked the database connection, and it seems to be active with no apparent issues. Also, the Asterisk logs don’t reveal any specific errors related to ODBC or PJSIP.
Here are some steps I have already tried:
- Ensuring that the database and tables exist and are accessible.
- Reloading ODBC and PJSIP modules in Asterisk.
- Checking the Asterisk logs for any error messages or warnings.
I’m wondering if anyone in the community has faced a similar issue or might have insights into what could be going wrong. Any guidance or suggestions would be greatly appreciated!
Thank you for your time and assistance.
Best regards,
Henry