Music on Hold is played sometimes

I use a ring group for operators to receive incoming calls.
For unknown reasons, the music sometimes plays, sometimes not. No patterns can be identified. What could be the problem?
The problem was initially even with the default music. I thought that if I replaced it with a custom one, the problem would be solved, but no.
Also, if it’s important, my PBX has two trunks. The problem does not depend on the trunk; it occurs randomly on both.

You would need to pull logs for calls impacted and non impacted. Could be a missed SIP message. Are you running the distro? What version? Are you up-to-date?

FreePBX 16.0.33
Asterisk 16.30.0
Visually, Asterisk logs with and without music are no different. Lines always appear calling the audio folder “test”:

[2024-05-02 09:28:31] VERBOSE[13917][C-00000ce7] pbx.c: Executing [3081@from-pstn:10] Set("PJSIP/trunk", "CHANNEL(musicclass)=test") in new stack
[2024-05-02 09:28:31] VERBOSE[13917][C-00000ce7] pbx.c: Executing [3081@from-pstn:11] Set("PJSIP/trunk", "__MOHCLASS=test") in new stack
[2024-05-02 09:28:31] VERBOSE[13917][C-00000ce7] pbx.c: Executing [s@macro-dial:5] ExecIf("PJSIP/trunk", "1?Set(CHANNEL(musicclass)=test)") in new stack

Hi @monotoad
Good day, Is your selected MOH audio playing at the FreePBX side ? And which format you did uploaded your NOT Running Audio? Maybe you had select wrong codec ?
My suggestion is 1st try to test and hear your MOH audio from FreePBX side.
Then you can check in Linux CLI side /var/lib/asterisk/moh/ permissions and audio formatted codec (alaw, ulaw etc…).

That’s not a sufficient level of logging. You need a level that shows messages about actually playing the music. Actually that is Verbose level 3, which I think is the same level as your logging here (even on the obsolete version you are using), so the logs don’t seem to be showing music on hold here. If the logs are the same when it works, it still comes down to insufficient logging.

A Ring Group generally doesn’t answer the channel, it will send a PROGRESS until an extension answers. If you want to ensure that the channel is always answered so you can play MOH, try enabling that feature on the Inbound Route.

None of this needs to be done in the Inbound Route. The default Ring Group settings are to send Progress and to play Ringing in the MoH option. Simply put this generates dialplan that will issues a PlayTones(ring) for the ringing just before the Progress. Progress is just creating early media/generating a 183 vs a 180. It doesn’t matter if Progress is on or not, PlayTones(ring) changes the tones for the other side.

Now setting the MoH to something else besides Ring makes it so PlayTones(ring) isn’t generated in the dialplan and it updates the Dial() command to use m(mohcategory) which then plays that MoH back to the calling party while the contacts are being called.

[2024-05-02 09:28:31] VERBOSE[13917][C-00000ce7] pbx.c: Executing [3081@from-pstn:11] Set("PJSIP/trunk", "__MOHCLASS=test") in new stack

The above log entry shows that the Music on Hold is being set on the calling channel (inbound caller) in the inbound route. The call is going to hit the Ring Group, then depending on the settings of said Ring Group it will either do PlayTones(ring) so the caller will hear ringing or it will set the m() option on the Dial() command so the caller hears the selected MoH while contacts are being called…

Now once someone answers that call a puts that call on hold for whatever reason the callers channel will use the musicclass that was set in the aforementioned log entry. So the music on hold being played sometimes to a caller and sometimes not to another caller…probably means the one caller was put on hold.

Then again, without see a full log of how the call was process it is hard to say.

I also saw the line “Started music on hold” in the logs. Sorry for not attaching it.

I uploaded in .mp3 format and converted to all formats available to me - alaw, g722, gsm, ulaw.

Is your selected MOH audio playing at the FreePBX side ?

Well, if the caller’s call has been established with an operator, and call forwarding is required, then in this case the music plays with 100% probability.

Hmm. Thanks for the detailed answer, I’ll try to dig in this direction.

Replacing the ring group with a queue actually solved the problem, but I’m still wondering what the problem was.

This is consistent with what I posted above. A queue will answer the calling channel immediately while waiting for an agent to answer, where a ring group does not.

This is not true. Straight from the docs:

This application does not automatically answer and should be preceeded by an application such as Answer(), Progress(), or Ringing().

Read more here:

Edit: Here is the first few priorities of FreePBX generated dialplan for a queue

exten => 1000,1,Macro(user-callerid,)
exten => 1000,n,Set(__MCQUEUE=${EXTEN})
exten => 1000,n,Answer

So app_queue isn’t automatically answering the call, it’s being done by the Answer() application before the call hits the actual queue.

A key difference between a queue and a ring group, is that queues can ring out, for the caller, for many minutes, whereas ring groups are assumed to be answered quickly. Whilst, in some cases, this may not be the reality, if you didn’t answer the call early, for a normal queue, the call would be ended by the network, before it reached an agent.

If answer times are expected to be long, Queues are the construct you should use.

How fast a Ring Group can answer is a business logic decision. In FreePBX a ring group has a max ring time of 300 seconds. However, that is a limitation put on by FreePBX as all a Ring Group does is issue a Dial() command. That command could have one or more endpoints being dialled at the same time and much like any other Dial() command if no timeout is set the default is 136 years. A ring group does not hold the caller, it just dials the destinations as it is programmed to do. If none of the destinations answer, the call is routed to a post destination.

A queue on the other hand will hold the call for as long as told before even sending it to an agent. During that time the caller will hear hold music and could be given options to leave the queue. Much like a ring group, the queue will call the agents based on the strategy and how long the timeout is set for when calling agents. If none of the agents answer the call is pulled back into the queue. Now at that point the call can be held longer and the agents retried or the queue could kick the caller out and route it to a post destination.

I can program my queue to act just like a normal ring group but I can’t program my ring group to act like a queue.