Realtime + MusicOnHold + Asterisk 18.10 / 16.X

Dear All,

I have set up an Asterisk + Realtime under both Ubuntu and Debian.

Realtime works fine for all the services except MusicOnHold. I can not get MusicOnHold to query the database.

I have no idea why. I’ve tried with Asterisk 16.X (from debian and ubuntu packages), and I compiled from the sources from current.tgz on debian and ubuntu. Any of theses combinaison leads to a situation where MOH does not query the database.

I don’t know what I am doing wrong, but it seems that I’m missing the obvious.

Current setup: Asterisk 18.10 (on a debian server and a ubuntu server).

I am using MariaDB + ODBC.

cat /etc/odbc.ini
[asterisk]
Driver = MariaDB
Description = MySQL connection to ‘asterisk’ database
Server = localhost
Port = 3306
Database = asterisk
UserName = asterisk
Password = password
Socket = /var/run/mysqld/mysqld.sock
Trace = 1
TraceFile = /var/log/asterisk/odbc.log
TraceOptions= 3
charset = utf8

cat /etc/odbcinst.ini

Driver from the mariadb-connector-odbc package

Setup from the unixODBC package

[MariaDB]
Description=ODBC for MariaDB
Driver=/usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
UsageCount=1

extconfig.conf:
[settings]
musiconhold => odbc,asterisk
musiconhold_entry => odbc,asterisk
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
queues => odbc,asterisk,queues
queue_members => odbc,asterisk,queue_members
queue_rules => odbc,asterisk,queue_rules
queue_log => odbc,asterisk,queue_log
voicemail => odbc,asterisk,voicemail
meetme => odbc,asterisk,meetme

modules.conf:
autoload=yes
preload => res_odbc.so
preload => res_config_odbc.so
load = res_musiconhold.so

res_odbc.conf:
[asterisk]
enabled => yes
dsn => asterisk
username => asterisk
password => password
pre-connect => yes
max_connections => 20
logging => yes

grep -v ; /etc/asterisk/musiconhold.conf

[general]
[default]
mode=files
directory=moh

The MariaDB tables are as follow (generated by alembic):

MariaDB [asterisk]> describe musiconhold;
±------------±------------------------------------------------------------------±-----±----±--------------------±------------------------------+
| Field | Type | Null | Key | Default | Extra |
±------------±------------------------------------------------------------------±-----±----±--------------------±------------------------------+
| name | varchar(80) | NO | PRI | NULL | |
| mode | enum(‘custom’,‘files’,‘mp3nb’,‘quietmp3nb’,‘quietmp3’,‘playlist’) | YES | | NULL | |
| directory | varchar(255) | YES | | NULL | |
| application | varchar(255) | YES | | NULL | |
| digit | varchar(1) | YES | | NULL | |
| sort | varchar(10) | YES | | NULL | |
| format | varchar(10) | YES | | NULL | |
| stamp | datetime | YES | | current_timestamp() | on update current_timestamp() |
±------------±------------------------------------------------------------------±-----±----±--------------------±------------------------------+
8 rows in set (0.002 sec)

MariaDB [asterisk]> describe musiconhold_entry;
±---------±--------------±-----±----±--------±------+
| Field | Type | Null | Key | Default | Extra |
±---------±--------------±-----±----±--------±------+
| name | varchar(80) | NO | PRI | NULL | |
| position | int(11) | NO | PRI | NULL | |
| entry | varchar(1024) | NO | | NULL | |
±---------±--------------±-----±----±--------±------+
3 rows in set (0.002 sec)

MariaDB [asterisk]> select * from musiconhold;
±------±---------±----------±------------±------±-----±-------±--------------------+
| name | mode | directory | application | digit | sort | format | stamp |
±------±---------±----------±------------±------±-----±-------±--------------------+
| test | playlist | NULL | NULL | NULL | NULL | NULL | 2022-02-23 10:02:34 |
| test2 | files | /tmp | NULL | NULL | NULL | NULL | 2022-02-23 14:53:08 |
±------±---------±----------±------------±------±-----±-------±--------------------+
2 rows in set (0.001 sec)

MariaDB [asterisk]> select * from musiconhold_entry;
±-----±---------±-----------------------------------+
| name | position | entry |
±-----±---------±-----------------------------------+
| test | 1 | hp://domain.com/audio-file-1.gsm |
| test | 2 | h
p://domain.com/audio-file-2.gsm |
| test | 3 | h**p://domain.com/audio-file-3.gsm |
±-----±---------±-----------------------------------+

fusionpbx*CLI> reload res_odbc.so
Module ‘res_odbc.so’ reloaded successfully.
– Reloading module ‘res_odbc.so’ (ODBC resource)
[Feb 23 15:12:38] NOTICE[381441]: res_odbc.c:697 load_odbc_config: Registered ODBC class ‘asterisk’ dsn->[asterisk]

fusionpbx*CLI> reload extconfig
Module ‘extconfig’ reloaded successfully.
– Reloading module ‘extconfig’ (Configuration)
== Binding musiconhold to odbc/asterisk/musiconhold
== Binding musiconhold_entry to odbc/asterisk/musiconhold_entry
== Binding ps_endpoints to odbc/asterisk/ps_endpoints
== Binding ps_auths to odbc/asterisk/ps_auths
== Binding ps_aors to odbc/asterisk/ps_aors
== Binding ps_domain_aliases to odbc/asterisk/ps_domain_aliases
== Binding ps_endpoint_id_ips to odbc/asterisk/ps_endpoint_id_ips
== Binding ps_contacts to odbc/asterisk/ps_contacts
== Binding queues to odbc/asterisk/queues
== Binding queue_members to odbc/asterisk/queue_members
== Binding queue_rules to odbc/asterisk/queue_rules
== Binding queue_log to odbc/asterisk/queue_log
== Binding voicemail to odbc/asterisk/voicemail
== Binding meetme to odbc/asterisk/meetme

fusionpbx*CLI> moh show classes
Class: default
Mode: files
Directory: moh

fusionpbx*CLI> moh show files
Class: default
File: /var/lib/asterisk/moh/macroform-cold_day
File: /var/lib/asterisk/moh/macroform-the_simplicity
File: /var/lib/asterisk/moh/macroform-robot_dity
File: /var/lib/asterisk/moh/reno_project-system
File: /var/lib/asterisk/moh/manolo_camp-morning_coffee

echo “select count(*) from asterisk.musiconhold” | isql asterisk asterisk

±--------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
±--------------------------------------+
SQL> select count() from asterisk.musiconhold
±--------------------+
| count(
) |
±--------------------+
| 2 |
±--------------------+
SQLRowCount returns 1
1 rows fetched
SQL> root@fusionpbx:/etc/asterisk#

-- Executing [33973404041@inbound-pjsip:76] Answer("PJSIP/sipcore1-00000008", "") in new stack
-- Executing [33973404041@inbound-pjsip:77] BackGround("PJSIP/sipcore1-00000008", "test") in new stack

[Feb 23 16:30:07] WARNING[383572][C-00000003]: file.c:804 ast_openstream_full: File test does not exist in any format
[Feb 23 16:30:07] WARNING[383572][C-00000003]: file.c:1277 ast_streamfile: Unable to open test (format (alaw)): No such file or directory
[Feb 23 16:30:07] WARNING[383572][C-00000003]: pbx_builtins.c:1239 pbx_builtin_background: ast_streamfile failed on PJSIP/sipcore1-00000008 for test

Asterisk 18.10.0 - Server version: 10.3.32-MariaDB-0ubuntu0.20.04.1-log Ubuntu 20.04

The queries log of MariaDB shows that MOH is not querying MariaDB while endpoints, aors, contacts, subscriptions, and so on are doing fine.

Did anyone encounter such a problem ? Any ideas welcome.

Kind Regards

I’m not sure if the CLI commands would even show classes from realtime if they haven’t been loaded yet. Additionally Background isn’t music on hold. It plays a file. The Musiconhold dialplan application will play music on hold.

oh cr*p…

You are right … It actually works fine with musiconhold()…
Classes show up with ‘moh show classes’ once musiconhold() has been executed.

*CLI> moh show classes
Class: default
Mode: files
Directory: moh
Class: test
Mode: playlist
Directory: nodir
Format: slin

I’ve been messing around during 24 hours without even realising I wasn’t calling the correct application.

It works perfectly fine.

You can close the topic. Sorry for the inconvenience and thank you very much for your help :slight_smile:

1 Like

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