Fixing Asterisk PJSIP 488 Not Acceptable Here SRTP and Codec
calricon / field note
Title: Fixing Asterisk PJSIP 488 Not Acceptable Here SRTP and Codec Errors Slug: fixing-asterisk-pjsip-488-not-acceptable-here-srtp-codec Focus Keyword: asterisk pjsip 488 not acceptable here Meta Title: Fix Asterisk PJSIP 488 Not Acceptable Here & SRTP...
Fixing Asterisk PJSIP 488 Not Acceptable Here SRTP and Codec Errors
Asterisk res_pjsip deployments bridging WebRTC browsers, TLS desk phones, and PSTN SIP trunks frequently reject inbound or outbound INVITE requests—or re-INVITEs during hold and transfer—with SIP/2.0 488 Not Acceptable Here, even when endpoints register cleanly and signaling over port 5060 or 5061 succeeds.
A 488 rejection means the receiving peer could not negotiate an acceptable SDP media session. Beyond simple codec mismatches (such as offering only opus to a ulaw-only PSTN trunk), the most common hidden culprit is an SDP media-profile or SRTP keying mismatch: mixing plain RTP/AVP, SDES-SRTP (RTP/SAVP with a=crypto), and WebRTC DTLS-SRTP (UDP/TLS/RTP/SAVPF with a=fingerprint) across incompatible endpoint templates.
Problem Diagnosis & Root Cause Architecture
Diagnosing a 488 Not Acceptable Here requires inspecting the exact SDP m=audio profile, a=crypto/a=fingerprint attributes, and codec intersection on the rejecting leg:
- SDES vs. DTLS-SRTP Keying Mismatch: Desk phones and TLS SIP trunks typically use SDES-SRTP (
media_encryption=sdes, carrying keys in SDPa=cryptooverRTP/SAVP), whereas WebRTC browsers require DTLS-SRTP (media_encryption=dtls, negotiating keys on the media socket viaUDP/TLS/RTP/SAVPF). Applying WebRTC encryption settings to a standard SIP trunk triggers an immediate488. - Strict
m=audioProfile Enforcement (RFC 3711 / 4568): PJSIP rejects non-compliant offers that attacha=cryptoattributes onto a plainRTP/AVPmedia line, or offers requiringRTP/SAVPwhenmedia_encryption=nois set on the endpoint. - Zero Codec Intersection or Missing Transcoder: If an endpoint restricts
disallow=allandallow=opuswithout permittingulaw/alaw(or lackscodec_opusfor transcoding to a G.711 carrier trunk), Asterisk returns488during SDP negotiation. media_encryption_optimistic=yesInterop Traps: Enabling optimistic SRTP can emit hybrid attributes that strict SBCs or mobile SIP stacks reject with488.
Never blindly setallow=allor disable SRTP globally to silence a488error. Isolate WebRTC, SDES-TLS, and plain-RTP PSTN trunks into separatepjsip.confendpoint templates so each leg negotiates its exact required media profile.
Why Standard Implementations Fail
1. Sharing One Endpoint Template Between WebRTC and Desk Phones
Attaching webrtc=yes or use_avpf=yes to a generic extension template causes standard UDP/TCP desk phones to reject SDP offers with 488.
2. Assuming Installed Codecs Are Permitted on the Endpoint
Having codec_opus.so or codec_g729a.so loaded in Asterisk does not enable it for a trunk—only codecs explicitly listed in the endpoint's allow= directive participate in SDP offers and answers.
3. Debugging Only the Phone Leg Instead of the Trunk Leg
When a PBX bridges two legs, the PSTN carrier may return 488 on the outbound trunk leg, which Asterisk propagates back to the extension—making the extension appear misconfigured.
Validated Step-by-Step Resolution Playbook
Step 1: Capture the Failing SDP Offer and Identify the Rejecting Leg
Enable PJSIP logging or run sngrep during a test call and inspect the m=audio line, a=rtpmap codecs, and a=crypto/a=fingerprint attributes right before the 488 response:
asterisk -rx "pjsip set logger on"
asterisk -rx "core show translation"
sngrep -d any port 5060Step 2: Separate Endpoint Templates by Media Profile in pjsip.conf
Define distinct endpoint templates for plain-RTP PSTN trunks, SDES-encrypted SIP trunks, and DTLS WebRTC clients with explicit codec intersections:
; 1. Plain RTP PSTN Trunk
[pstn-trunk-tpl](!)
type=endpoint
disallow=all
allow=ulaw,alaw
media_encryption=no
direct_media=no
; 2. SDES-SRTP SIP TLS Trunk
[sdes-tls-tpl](!)
type=endpoint
disallow=all
allow=ulaw,alaw,g722
media_encryption=sdes
media_encryption_optimistic=no
direct_media=no
; 3. Browser WebRTC Endpoint (DTLS-SRTP)
[webrtc-tpl](!)
type=endpoint
disallow=all
allow=opus,ulaw
webrtc=yes
direct_media=noStep 3: Verify Loaded Codec Modules & Translation Paths
Ensure required codec modules (such as codec_opus.so when bridging WebRTC Opus to PSTN G.711 ulaw) are loaded and active in Asterisk:
asterisk -rx "module show like codec"
asterisk -rx "core show codecs audio"Step 4: Production Verification
Reload res_pjsip, inspect the resolved endpoint configuration, and place a test call across both internal and PSTN trunk paths while verifying two-way audio and zero 488 rejections:
asterisk -rx "module reload res_pjsip.so"
asterisk -rx "pjsip show endpoint sdes-trunk"
asterisk -rx "pjsip set logger off"With segregated endpoint templates, matched SDES/DTLS profiles, and verified codec translation paths, Asterisk PJSIP negotiates clean SDP sessions across mixed WebRTC and PSTN trunks.
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.