Treat optimization as a topology transition
A Local channel has two linked halves. When both halves are bridged and optimization is permitted, Asterisk can remove them from the media path so the channels behind them communicate directly. That disappearance is not by itself a hangup or failed call.
Capture both Local channel names, unique IDs, linked ID, their bridge membership and the channels behind them before interpreting a missing Local name. Preserve the surviving channels and final bridge rather than expecting the original Local identities to remain addressable.
Read /n as an intentional retention decision
The /n modifier prevents automatic optimization and keeps the Local channel in the call path. Use it when later behavior depends on Local-channel variables, dialplan state, limits, hooks or an addressable Local identity. The Local optimization reference shows why a time limit can be lost when the Local channel optimizes away.
The /j jitter-buffer modifier must be used with /n so the Local channel remains available to host it. Record the exact dial string and modifiers; do not infer them from an earlier configuration example.
Bound LocalOptimizeAway precisely
The AMI LocalOptimizeAway action takes an ActionID and a Local Channel. For a channel created with /n, the documented action clears the prohibition and allows optimization if the channel is bridged or when it later becomes bridged. It does not promise an immediate or successful transition.
Resolve the current Local half at action time and correlate the action response. Keep permission, parsing, missing-channel and topology failures separate from a later optimization result.
Correlate Begin and End by operation ID
LocalOptimizationBegin reports both Local halves, the source channel and destination bridge identity when optimization starts. Retain its operation Id. LocalOptimizationEnd uses that same Id and provides Success, which is the explicit completion result for that attempt.
A LocalBridge event reports the two halves plus LocalOptimization Yes or No, but it is not a substitute for the correlated Begin and End outcome. Preserve event order, timestamps and stable identities.
Expect bridge movement or bridge merging
The AMI v2 specification describes two possible topology consequences. If either bridge has only one channel after optimization, that channel can move into the other bridge, exposed through bridge-leave and bridge-enter events. If both bridges contain multiple channels, the bridges can merge.
Do not hard-code a single bridge ID or assume the pre-optimization membership snapshot remains authoritative. Re-enumerate the surviving topology after the correlated End event.
Keep query and media behavior explicit
The /b modifier changes Local-channel queries to return the actual channel behind the Local channel, which can matter to transfer workflows. The /m modifier forwards music-on-hold start and stop indications instead of handling them locally. These modifiers solve different problems from /n.
After optimization, verify variable ownership, feature and recording continuity, bridge membership, negotiated streams, packet flow and audible media in both directions. No PBX, AMI session, manager user, permission, dialplan, Local channel, bridge, packet, media stream or live call was inspected or tested for this guide.
Re-snapshot identities after Local optimization
The AMI channel snapshots guide explains Local traversal, stable IDs and mutable bridge membership.
Preserve optimization events across session filtering
The AMI event diagnostic verifies dynamic filters, reconnect state and downstream parsing.
Sources & applicability
Primary references for the technical details above. Operational examples and planning checklists are VoIP.info editorial guidance.
- Asterisk 23 AMI LocalOptimizeAway action ↗
- Asterisk 22 AMI LocalOptimizeAway action ↗
- Asterisk 23 AMI LocalOptimizationBegin event ↗
- Asterisk 23 AMI LocalOptimizationEnd event ↗
- Asterisk 23 AMI LocalBridge event ↗
- Asterisk AMI v2 specification: Local channel optimization ↗
- Asterisk Local channel optimization ↗
- Asterisk Local channel modifiers ↗
- Asterisk 23 AMI CoreShowChannelMap action ↗
- Asterisk 22 AMI CoreShowChannelMap action ↗
- Asterisk 23 AMI CoreShowChannelMapComplete event ↗
- Asterisk 22 AMI CoreShowChannelMapComplete event ↗
- Asterisk 23 AMI CoreShowChannels action ↗
- Asterisk 23 AMI CoreShowChannel event ↗
- Asterisk 23 AMI CoreShowChannelsComplete event ↗
- Asterisk 23 AMI Status action ↗
- Asterisk 23 AMI Status event ↗
- Asterisk 23 AMI StatusComplete event ↗
- Asterisk 23 AMI Newchannel event ↗
- Asterisk 23 AMI Rename event ↗
- Asterisk 23 AMI Events action ↗
- Asterisk 22 AMI Events action ↗
- Asterisk 23 AMI Filter action ↗
- Asterisk 22 AMI Filter action ↗
- Asterisk 23 AMI WaitEvent action ↗
- Asterisk 22 AMI WaitEvent action ↗
- Asterisk AMI event filtering ↗
- Asterisk Manager TCP/IP API ↗
- Asterisk 23 AMI Login action ↗
- Asterisk 23 AMI Ping action ↗
Examples require adaptation to your topology. No live PBX or hardware testing is claimed.