Local channel not being optimized out of call path

As I understand, Local channel will try to optimize itself out of the call path by default, as long the “n” option is not set. However, after the real destination answers, I can still see local channels in active channel list. Is this a bug, or are there some conditions that can prevent optimization? Asterisk version is 15.1.5.

queues.conf

[general]
autofill=yes
shared_lastcall=yes
monitor-type=MixMonitor
updatecdr=yes

[StandardQueue](!)
strategy=ringall
joinempty=no
leavewhenempty=yes
ringinuse=yes
timeout=60
retry=1
announce-position=no
setqueueentryvar=yes
setinterfacevar=yes

[Test](StandardQueue)
announce-position=no
announce-holdtime=no
periodic-announce=
announce-frequency=0
periodic-announce-frequency=0
min-announce-frequency=0
member => Local/605@agent-dial,,PJSIP/605,hint:605@phones

extensions.ael

context agent-dial {
    _X. => {
        Dial(${PJSIP_DIAL_CONTACTS(${EXTEN})},,);
    }
}

asterisk -rnx "core show channels verbose"

Channel              Context              Extension        Prio State   Application  Data                      CallerID        Duration Accountcode PeerAccount BridgeID            
Local/605@agent-dial agent-dial           605                 1 Up      Dial         PJSIP/605/sips:605@82.214 0123456789      00:00:20                         8d648b20-3ff4-4849-8
Local/605@agent-dial agent-dial           12345678901         1 Up      AppQueue     (Outgoing Line)           605             00:00:20                         47ecae2e-7f3a-4c52-a
PJSIP/akton123-00000 bridge               12345678901       191 Up      Queue        Test,htkxC,,,3            0123456789      00:00:28                         47ecae2e-7f3a-4c52-a
PJSIP/605-0000028d   phones                                   1 Up      AppDial      (Outgoing Line)           605             00:00:20                         8d648b20-3ff4-4849-8
4 active channels
2 active calls

When a Local channel optimizes, Asterisk has to take the “real” channels at either end of the call and merge them down into a single bridge. That happens via a sequence of merges and swaps (depending on the bridge configuration).

Various things can prevent that. In some circumstances, Asterisk will create a bridge that explicitly prevents a swap or a merge operation from occurring. This is usually done when there may be harmful effects that occur when a bridge “loses” in a merge or swap operation.

If I recall correctly, bridges created via Queue have some restrictions placed on them, particularly in the case where Agents may be always on a phone. Looking at the code, it appears like we only allow channels to be swapped into a bridge created in Queue:

		bridge = ast_bridge_call_with_flags(qe->chan, peer, &bridge_config,
				AST_BRIDGE_FLAG_MERGE_INHIBIT_FROM | AST_BRIDGE_FLAG_MERGE_INHIBIT_TO | AST_BRIDGE_FLAG_SWAP_INHIBIT_FROM);

I honestly can’t remember the reasons for it, but it’s possible @jcolp or one of the other developers will remember why those restrictions were put in place.

2 Likes

I do not recall, but it may be because Queue wants to have tighter control over the bridge. It could also be to simplify tracking things. Those are what come to mind.

Thanks for the explanation. So, I can safely assume that, in case of calls to queue agents, local channels will never be optimized out? Unless this behavior is changed in some future version of Asterisk, of course.

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