Local Channel Optimization Problem

Asterisk 18.6.0

Greetings all! I have a queue where I’m sending calls to local channel (without the /n but doesn’t seen to matter, tried both ways) and the local channels never optimize themselves out. Shouldn’t the two local channels automatically optimize out or am I misunderstanding something?

queues.conf:

member=>Local/100@contacts

extensions.conf:

[contacts]
exten => 100,1,Dial(${PJSIP_DIAL_CONTACTS(100)})

Results in these channels:

Local/100@contacts-000001ad;2
Local/100@contacts-000001ad;1
PJSIP/inbound-00000320
PJSIP/100-00000324

Thanks for any enlightenment :slight_smile:

In Asterisk 11 and earlier, local channels optimized themselves out by using masquerades. In Asterisk 12 and later, local channels optimize themselves out when they are attached between bridges (except ConfBridge and ARI managed bridges). In both cases, frames must be flowing through the local channels. There are other reasons why a local channel cannot optimize itself out of a channel chain. Many of those reasons have to do with preventing something in Asterisk from loosing track of the channels.

Thanks, rmudgett!

Here is the same example with bridge ids. Since the two PJSIP channels are using the same bridges as the local channels shouldn’t the local channels optimize out?

Local/100@contacts-000001ad;2 … 243e21a1-a686-48b9-b9ab-7d8a3092d6fa
Local/100@contacts-000001ad;1 … b77241d3-1dd9-4af0-914d-0e6d35d930e6
PJSIP/inbound-00000320 … b77241d3-1dd9-4af0-914d-0e6d35d930e6
PJSIP/100-00000324 … 243e21a1-a686-48b9-b9ab-7d8a3092d6fa

At any rate, thanks for the explanation, much appreciated!

PJSIP/inbound --> app_queue-bridge --> L;1 -- L;2 --> app_dial-bridge --> PJSIP/100

From your provided information, the above is what I think your channel chain looks like.

The app_queue bridge has to keep track of channels in its bridge for the queue logging to track transfers so it restricts how local channels can optimize. The restriction is that local channels can only optimize out by pulling channels towards the app_queue bridge. i.e., It can only optimize by pulling the PJSIP/100 channel toward the app_queue bridge by swapping it with the L;1 channel.

The app_dial bridge does not place any restrictions on optimization. When the PJSIP/100 channel is answered, app_dial creates its bridge and places PJSIP/100 and L;2 into the bridge.

The local channels were created without the /n option to allow optimization.

This scenario should allow optimization if audio frames are passing through. Since the app_queue bridge imposes a restriction, the frames have to be flowing in a particular direction. I don’t remember which but I think the frames have to be flowing from PJSIP/100 to the app_queue bridge.