Caller listens to music for around 40 seconds after call is patched to agent and agent listens to some prompt

Hi, I am trying to use ARI Bridges. I originate a call to my IP Phone by creating a channel and once it is answered I place both the channels in the bridge. Now what happens is the caller listens to some music (may be MOH) and when the Agent answers the call on IP Phone he listens to a prompt “Please Dial the Called Number”. The music on Caller’s channel continues till about 40-45 seconds after which the voice gets through and both can talk.

I don’t know what is happening in the first 40 seconds of the call.

But when I use Dial function in extensions.conf to patch to the same agent there is no such issue.
The logs from asterisk console are attached below.

Activating Stasis app ‘ACD’
== WebSocket connection from ‘’ for protocol ‘’ accepted using version ‘13’
– Accepting call from ‘07087561823’ to ‘2556251’ on channel 0/8, span 1
– Executing [2556251@from-pstn:1] GotoIf(“DAHDI/i1/07087561823-8”, “1?temp:”) in new stack
– Goto (from-pstn,2556251,3)
– Executing [2556251@from-pstn:3] Goto(“DAHDI/i1/07087561823-8”, “temp,_X!,1”) in new stack
– Goto (temp,_X!,1)
– Executing [_X!@temp:1] Verbose(“DAHDI/i1/07087561823-8”, “1, “TEMP ACD Testing””) in new stack
"TEMP ACD Testing"
– Executing [_X!@temp:2] Set(“DAHDI/i1/07087561823-8”, “lang=en”) in new stack
– Executing [_X!@temp:3] Answer(“DAHDI/i1/07087561823-8”, “”) in new stack
– Executing [_X!@temp:4] Stasis(“DAHDI/i1/07087561823-8”, “ACD”) in new stack
– <DAHDI/i1/07087561823-8> Playing ‘/usr/share/um/media/prompts/ivr/waiting_en.slin’ (language ‘en’)
– Called 10010
– PJSIP/10010-00000005 is ringing
> 0x7f537001dad0 – Probation passed - setting RTP source address to
> 0x7f5370006d80 – Probation passed - setting RTP source address to
– PJSIP/10010-00000005 answered
> Launching Stasis(ACD,AGENT_CH) on PJSIP/10010-00000005
– Channel DAHDI/i1/07087561823-8 joined ‘simple_bridge’ stasis-bridge
– Channel PJSIP/10010-00000005 joined ‘simple_bridge’ stasis-bridge
[Feb 26 17:30:02] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:05] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:08] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:11] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:14] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:17] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:20] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:23] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:26] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
[Feb 26 17:30:29] WARNING[17646]: netsock2.c:210 ast_sockaddr_split_hostport: Port missing in (null)
– Channel PJSIP/10010-00000004 left ‘simple_bridge’ stasis-bridge
– Channel PJSIP/10010-00000005 left ‘simple_bridge’ stasis-bridge
– Channel DAHDI/i1/07087561823-8 left ‘simple_bridge’ stasis-bridge
– Hungup ‘DAHDI/i1/07087561823-8’
[Feb 26 17:30:50] WARNING[19127]: res_http_websocket.c:519 ws_safe_read: Web socket closed abruptly
[Feb 26 17:30:50] WARNING[19127]: ari/ari_websockets.c:128 ast_ari_websocket_session_read: WebSocket read error: Success
Deactivating Stasis app ‘ACD’
== WebSocket connection from ‘’ closed

How are you starting the music? In your application? If so, are you explicitly stopping it in your application?

Hi, Thanks for the response, I am not starting this music in my application. It is playing by itself :frowning: . More over the prompt that Agent is listening to is also playing by itself. On Agent’s IP Phone it says some thing like “Please enter the call number”.
And when agent presses the # DTMF the voice gets through after 2-3 small beeps.

It seems the Agent call is somehow first routed to some other dialplan/application by asterisk due to some reason.

This is my dialplan:


exten =>_X!,1,gotoif($["${CALLERID(number)}"==“07087561823”]?temp:)

exten =>_X!,2,Goto(ServiceOPQ,_X!,1)
exten =>_X!,3(temp),Goto(temp,_X!,1)

exten => _X!,1,Verbose(1, “TEMP ACD Testing”)
same => n, Set(lang=en)
same => n, Answer()
same => n, Stasis(ACD)

Below is a sample snipet of my code where i am creating channels and bridge.

var cfg = require(’./config’);
var aq = require(’./agent_queue’);
var caller_queue = require(’./caller_queue’);

function DialingState(call) {
this.state_name = “dialing”;
var ccBridge = null;
this.enter = function() {
console.log(“Entering dialing state”);“ChannelHangupRequest”, on_hangup);
console.log(“Will Dial the allocated Agent:”, call.allocated_agent);
var newBridgeId = + “_” + call.allocated_agent;
function cleanup() {‘ChannelHangupRequest’, on_hangup);

    function on_hangup(event, channel) {
    function originate(channel) {
        var dialed = call.client.Channel();
        var endPoint = "SIP/"+call.allocated_agent;
        channel.on('StasisEnd', function(event, channel) {
            hangupDialed(channel, dialed);
        dialed.on('ChannelDestroyed', function(event, dialed) {
            hangupOriginal(channel, dialed);
        dialed.on('Ring', function(event, dialed) {
        dialed.on('StasisStart', function(event, dialed) {
            console.log("Stasis Started for dialed");
            joinCCBridge(channel, dialed);
            {endpoint: endPoint, app: 'ACD', appArgs: 'AGENT_CH', callerId:"20000 <2000>"},
            function(err, dialed) {
                if (err) {
                    throw err;
    function hangupDialed(channel, dialed) {
                'Channel %s left our application, hanging up dialed channel %s',

        // hangup the other end
        dialed.hangup(function(err) {
                // ignore error since dialed channel could have hung up, causing the
                // original channel to exit Stasis

    // handler for the dialed channel hanging up so we can gracefully hangup the
    // other end
    function hangupOriginal(channel, dialed) {
        console.log('Dialed channel %s has been hung up, hanging up channel %s',

        // hangup the other end
        channel.hangup(function(err) {
                // ignore error since original channel could have hung up, causing the
                // dialed channel to exit Stasis
    function joinCCBridge(channel, dialed) {
        var bridge = call.client.Bridge();

        dialed.on('StasisEnd', function(event, dialed) {
                dialedExit(dialed, bridge);

        dialed.answer(function(err) {
                if (err) {
                throw err;
                console.log("Dialed Channel Answered. Inform CRM about patching here");
                addChannelsToBridge(channel, dialed, bridge);

        bridge.create({type: 'mixing,dtmf_events,proxy_media'}, function(err, bridge) {
                if (err) {
                throw err;

                console.log('Created bridge %s',;

    function dialedExit(dialed, bridge) {
                'Dialed channel %s has left our application, destroying bridge %s',

        bridge.destroy(function(err) {
                if (err) {
                throw err;
    function addChannelsToBridge(channel, dialed, bridge) {
        console.log('Adding channel %s and dialed channel %s to bridge %s',

        bridge.addChannel({channel: [,]}, function(err) {
                if (err) {
                throw err;


module.exports = DialingState;

I am not sure if these logs could be the issue… or should i ignore these…

when I checked the status of the Dialed Channel through ARI this is what I got:


this shows that my dialed channel is going into context “public” some how, which is not what i intended. I want it to straight away go to my stasis application.

this is how i have configured my agent in sip.conf:

Is there some issue over here?? I have even checked by commenting out the context from sip.conf but of no use.

It’s not going into the context, that is merely what is on the channel due to its creation. It’s going directly into the Stasis application. Nothing sticks out from your provided information (console log, application) to explain why stuff is hearing music and playing. I’d try to narrow that down and figure it out.

Thanks, it would be great help indeed.

Hi, did you figure out any thing in this? I have identified that this case only happens when an inbound call terminates on my PRI and i bridge it with an agent on SIP. It is working fine if I make SIP inbound calls (using allowguest = yes in sip.conf).
Moreover this is also working fine on my 1st span/pri. I have 4 PRIs connected on my asterisk server this issue is coming on the last 3.
I have tried various asterisk versions (13.1, 13.8-certified and 14.1) but its same on all those.
Please let me know if I can provide any additional logs/information/configuration etc that would prove helpful to solve this.

Finally!! I got the issue, in chan_dahdi.conf, my PRI spans (2-4) were configured to switchtype=euroisdn and Span 1 was configured to switchtype=national when I changed all to national instead of euroisdn it worked fine on all spans.

But I could not find any explanation for this. Do you know what could the reason be?

I don’t know ISDN so I can’t comment on what kind of effect that would have had.