Fix FreeSWITCH 488 Not Acceptable Here Codec Mismatches
calricon / field note
Eliminate FreeSWITCH SIP 488 Not Acceptable Here and
Fix FreeSWITCH 488 Not Acceptable Here Codec Mismatches
In production FreeSWITCH SBC and PBX deployments, inbound carrier trunks or WebRTC-to-PSTN bridges frequently reject calls before ringback with SIP/2.0 488 Not Acceptable Here and hangup cause INCOMPATIBLE_DESTINATION. Simultaneously, freeswitch.log logs [ERR] mod_sofia.c: CODEC NEGOTIATION ERROR, even though both endpoints support standard G.711 audio.
The verified root cause is a zero-intersection SDP media negotiation failure: either the incoming INVITE offers codecs absent from inbound-codec-prefs, early negotiation locks an incompatible A-leg codec before bridging to the B-leg, or the remote SDP specifies an encrypted transport profile (RTP/SAVP or UDP/TLS/RTP/SAVPF) on a profile configured only for plain RTP/AVP.
Problem Diagnosis & Root Cause Architecture
When mod_sofia receives an INVITE, it intersects the remote SDP m=audio payload list and media transport against the SIP profile's local configuration. Four common mismatches trigger 488 rejections:
- Missing Codec Intersection: If a carrier SBC offers
G729andPCMAwhilevars.xmlrestrictsglobal_codec_prefstoOPUS,G722,PCMU, FreeSWITCH finds zero overlapping codecs and immediately responds with488. - Passthrough-Only G.729 Limitations: Default FreeSWITCH builds load
mod_g729in passthrough-only mode. Bridging a G.729 trunk to an IVR, conference, or Opus WebRTC endpoint fails because transcoding is unavailable. - Early Negotiation Codec Lock-In: With
inbound-late-negotiationset tofalse, FreeSWITCH selects the A-leg codec before executing the dialplan, causing488orINCOMPATIBLE_DESTINATIONif the B-leg carrier rejects that codec. - RTP/AVP vs. RTP/SAVP Transport Mismatch: Sending SRTP (
RTP/SAVP) or WebRTC DTLS-SRTP offers to a plain SIP profile withoutrtp_secure_mediaenabled—or vice versa—fails SDP validation immediately.
A SIP 488 INCOMPATIBLE_DESTINATION failure is almost always an SDP intersection or early-negotiation problem; enabling late negotiation lets FreeSWITCH align A-leg and B-leg codecs before committing media.
Why Standard Implementations Fail
1. Relying on Default global_codec_prefs Without Carrier Alignment
Default vars.xml templates prioritize wideband codecs like G722 and OPUS, or omit PCMA in regions where A-law is mandatory, causing carrier IP migrations to fail overnight.
2. Forcing Transcoding Instead of Inheriting Codecs
Bridging across mismatched codecs wastes CPU and degrades voice quality; when mod_g729 is passthrough-only, transcoding is impossible and the bridge aborts.
3. Disabling Encryption Without Checking Offer Transport
Leaving rtp_secure_media unset on profiles receiving WebRTC or TLS-SRTP trunks causes mod_sofia to reject every SAVP or SAVPF media line.
Step-by-Step Resolution Playbook
Step 1: Capture Live SDP Offers and Codec Modules in fs_cli
Enable Sofia SIP tracing in fs_cli to inspect the exact m=audio codecs and transport profile in the failing INVITE, and list loaded codecs:
fs_cli -x "sofia global siptrace on"
fs_cli -x "sofia loglevel all 9"
fs_cli -x "show codecs"Step 2: Align global_codec_prefs and outbound_codec_prefs
Update /etc/freeswitch/vars.xml so both PCMU and PCMA are included alongside wideband codecs matching your carriers and endpoints:
<X-PRE-PROCESS cmd="set" data="global_codec_prefs=OPUS,G722,PCMU,PCMA"/>
<X-PRE-PROCESS cmd="set" data="outbound_codec_prefs=OPUS,G722,PCMU,PCMA"/>Step 3: Enable Late Negotiation and Inherit Codec in mod_sofia
Configure inbound-late-negotiation in your SIP profile (/etc/freeswitch/sip_profiles/external.xml or internal.xml) and set inherit_codec=true in the dialplan so the B-leg answer dictates the A-leg codec:
<!-- In /etc/freeswitch/sip_profiles/external.xml -->
<param name="inbound-codec-negotiation" value="generous"/>
<param name="inbound-late-negotiation" value="true"/><!-- In dialplan before bridge -->
<action application="set" data="inherit_codec=true"/>
<action application="bridge" data="sofia/gateway/carrier_trunk/$1"/>If bridging encrypted trunks or WebRTC clients, ensure rtp_secure_media=true (or optional) is set on the corresponding dialplan leg or profile.
Step 4: Reload mod_sofia and Verify SDP Intersection
Rescan the modified SIP profile, place a test call, and verify that both legs negotiate a matching codec with 200 OK:
fs_cli -x "reloadxml"
fs_cli -x "sofia profile external rescan"
fs_cli -x "show channels"Confirm in show channels that read_codec and write_codec match across both bridged legs and that siptrace shows zero 488 Not Acceptable Here responses.
Experiencing this issue in your production systems?
Calricon conducts senior-level VoIP, SIP trunking, Asterisk, and cloud infrastructure audits. We review your live configs, identify packet drops or contention bottlenecks, and provide exact remediation runbooks.