VoIP.info Guide

Asterisk AMI Local-channel optimization and identity

Control when Local channel halves may leave the media path, correlate Begin and End events, and preserve identity, variables and bridge evidence across optimization.

Reviewed 2026-10-16Current Asterisk branch-23-generated LocalOptimizeAway, LocalOptimizationBegin, LocalOptimizationEnd and LocalBridge references plus the branch 22 action, AMI v2 specification and Local-channel optimization and modifier references reviewed October 16, 2026; installed branch, loaded action and events, AMI permissions, dial string, Local modifiers, channel identities, bridge topology, variables, recording hooks, signaling and media remain deployment specific; no PBX, AMI session, manager user, permission, dialplan, Local channel, bridge, packet, media stream or live call was inspected or testedAdvancedDocumentation based · not lab tested

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.

Examples require adaptation to your topology. No live PBX or hardware testing is claimed.