📋 问题现象 错误特征 呼叫正常接通,但单侧无声音 (一方能听到,另一方听不到)。
常见场景
✅ 呼叫正常建立
✅ 双方都能听到回铃音
❌ 接通后一方无声音(单向静音)
❌ RTP 流未正常传输
🔍 问题根源 可能原因
RTP 媒体流未正常建立
编解码器不匹配
NAT 问题
媒体流方向问题
read 方向(收)或 write 方向(发)失败
✅ 解决步骤 步骤 1: 找到通话的 Channel UUID 使用 show channels 命令 :
1 2 3 4 5 6 7 8 9 10 11 fs_cli show channels uuid name state cid_num ------------------------------------ ---------------- ------------- ---------- a1b2c3d4-e5f6-7890-abcd-ef1234567890 sofia/internal/... CS_EXECUTE 1001 b2c3d4e5-f6a7-8901-bcde-f12345678901 sofia/internal/... CS_EXECUTE 1002
输出说明 :
获取主被叫双方的 UUID :
1 2 3 4 5 6 7 8 9 show channels | grep 1001 uuid_dump a1b2c3d4-e5f6-7890-abcd-ef1234567890
步骤 2: 开启媒体流调试 使用 uuid_debug_media 命令 :
1 2 3 4 5 6 7 uuid_debug_media <uuid> <direction> <on|off>
示例 1: 调试主叫方的媒体流
1 2 3 4 5 uuid_debug_media a1b2c3d4-e5f6-7890-abcd-ef1234567890 both on
示例 2: 调试被叫方的媒体流
1 2 uuid_debug_media b2c3d4e5-f6a7-8901-bcde-f12345678901 both on
示例 3: 只调试单向媒体流
1 2 3 4 5 uuid_debug_media a1b2c3d4-e5f6-7890-abcd-ef1234567890 read on uuid_debug_media a1b2c3d4-e5f6-7890-abcd-ef1234567890 write on
步骤 3: 查看媒体流调试信息 开启调试后,让用户通话,观察日志 :
1 2 3 4 5 tail -f /usr/local/freeswitch/log/freeswitch.logconsole loglevel 7
正常日志示例(有声音) :
1 2 3 4 [DEBUG] switch_rtp.c:1234 Read audio packet 160 bytes [DEBUG] switch_rtp.c:2345 Write audio packet 160 bytes [DEBUG] switch_rtp.c:3456 Read audio packet 160 bytes [DEBUG] switch_rtp.c:4567 Write audio packet 160 bytes
异常日志示例(无声音 - 单向) :
1 2 3 4 [DEBUG] switch_rtp.c:1234 Read audio packet 160 bytes [WARNING] switch_rtp.c:2345 No audio packets to write [DEBUG] switch_rtp.c:3456 Read audio packet 160 bytes [WARNING] switch_rtp.c:4567 No audio packets to write
异常日志示例(无声音 - 双向) :
1 2 3 4 [WARNING] switch_rtp.c:1234 No audio packets to read [WARNING] switch_rtp.c:2345 No audio packets to write [WARNING] switch_rtp.c:3456 RTP timeout [ERR] switch_rtp.c:4567 RTP stream inactive
步骤 4: 分析问题原因 根据日志判断问题类型 :
情况 1: read 方向无包(收不到) 日志特征 :
1 [WARNING] switch_rtp.c:1234 No audio packets to read
可能原因 :
对方未发送 RTP 包
防火墙阻止入站 RTP
RTP 端口不正确
NAT 映射问题
解决方案 :
1 2 3 4 5 6 7 8 9 10 11 12 fs_cli -x "eval \${rtp_port_min}" fs_cli -x "eval \${rtp_port_max}" sudo iptables -L -n | grep 10000:20000sudo iptables -I INPUT -p udp --dport 10000:20000 -j ACCEPTfs_cli -x "nat_map status"
情况 2: write 方向无包(发不出) 日志特征 :
1 [WARNING] switch_rtp.c:2345 No audio packets to write
可能原因 :
本地未生成 RTP 包
编解码器问题
媒体流未正常建立
解决方案 :
1 2 3 4 5 6 7 8 9 10 fs_cli -x "uuid_getvar <uuid> read_codec" fs_cli -x "uuid_getvar <uuid> write_codec" fs_cli -x "uuid_park <uuid>" fs_cli -x "show rtp" fs_cli -x "uuid_dump <uuid>"
情况 3: 双向都有包,但听不到 日志特征 :
1 2 [DEBUG] switch_rtp.c:1234 Read audio packet 160 bytes [DEBUG] switch_rtp.c:2345 Write audio packet 160 bytes
可能原因 :
解决方案 :
1 2 3 4 5 6 7 8 fs_cli -x "uuid_getvar <uuid> codec_string" fs_cli -x "uuid_setvar <uuid> absolute_codec_string=PCMU"
步骤 5: 关闭媒体流调试 调试完成后,关闭调试 :
1 2 3 4 5 6 7 8 9 uuid_debug_media a1b2c3d4-e5f6-7890-abcd-ef1234567890 both off uuid_debug_media a1b2c3d4-e5f6-7890-abcd-ef1234567890 read off uuid_debug_media a1b2c3d4-e5f6-7890-abcd-ef1234567890 write off
⚠️ 注意 : 调试模式会产生大量日志,生产环境调试完成后务必关闭。
🚨 常见问题 现象 :
1 [ERR] uuid_debug_media: Command not found
原因 : FreeSWITCH 版本过旧或模块未加载
解决方案 :
1 2 3 4 5 6 7 8 9 10 11 12 fs_cli -x "version" fs_cli -x "module_exists mod_console" fs_cli -x "load mod_console" fs_cli -x "uuid_park <uuid>" fs_cli -x "uuid_dump <uuid>"
问题 2: 找不到 UUID 现象 :
1 2 show channels # 输出为空或找不到特定号码
排查步骤 :
1 2 3 4 5 6 7 8 9 10 11 fs_cli -x "show channels" fs_cli -x "sofia status profile internal reg" fs_cli -x "show calls" fs_cli -x "show channels" | grep 1001
问题 3: 调试后日志量过大 现象 : 开启 both 调试后,日志暴增
解决方案 :
1 2 3 4 5 6 7 8 9 10 11 12 uuid_debug_media <uuid> read on uuid_debug_media <uuid> write on fs_cli -x "console loglevel 3" tail -f /usr/local/freeswitch/log/freeswitch.log | grep "Read audio\|Write audio" uuid_debug_media <uuid> both off
问题 4: RTP 端口被防火墙阻止 排查步骤 :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 fs_cli -x "eval \${rtp_port_min}" fs_cli -x "eval \${rtp_port_max}" sudo iptables -L -n -v | grep -E "16384:32768|10000:20000" sudo iptables -I INPUT -p udp --dport 16384:32768 -j ACCEPTsudo iptables -I OUTPUT -p udp --sport 16384:32768 -j ACCEPTsudo service iptables savesudo firewall-cmd --permanent --add-port=16384-32768/udpsudo firewall-cmd --reload
🔧 高级调试技巧 抓包分析 RTP 流 1 2 3 4 5 6 7 8 9 10 11 12 13 fs_cli -x "uuid_dump <uuid>" | grep -E "rtp_ip|audio_port" tcpdump -i eth0 -n host <remote_ip> and udp port <rtp_port> -s 0 -w /tmp/rtp.pcap tshark -r /tmp/rtp.pcap -q -z rtp-stream
检查 RTP 统计信息 1 2 3 4 5 6 7 8 9 10 11 12 13 fs_cli -x "show rtp" fs_cli -x "uuid_getvar <uuid> rtp_audio_in_packet_count" fs_cli -x "uuid_getvar <uuid> rtp_audio_out_packet_count" watch -n 1 'fs_cli -x "show rtp" | grep <uuid>'
测试编解码器 1 2 3 4 5 6 7 8 9 10 11 12 13 14 fs_cli -x "show codecs" fs_cli -x "uuid_getvar <uuid> read_codec" fs_cli -x "uuid_getvar <uuid> write_codec" fs_cli -x "uuid_setvar <uuid> absolute_codec_string=PCMU" fs_cli -x "uuid_setvar <uuid> absolute_codec_string=PCMA" fs_cli -x "uuid_setvar <uuid> absolute_codec_string=OPUS" fs_cli -x "uuid_setvar <uuid> codec_string="
📋 快速诊断流程图 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 呼叫单侧无声音 | ├─ 步骤 1: 找到通话 UUID | └─ show channels | ├─ 步骤 2: 开启媒体调试 | └─ uuid_debug_media <uuid> both on | ├─ 步骤 3: 观察日志 | | | ├─ read 无包? | | ├─ 是 → 检查入站防火墙、NAT、对方发送 | | └─ 否 → 继续 | | | ├─ write 无包? | | ├─ 是 → 检查编解码器、媒体流建立 | | └─ 否 → 继续 | | | └─ 双向都有包? | └─ 检查编解码器兼容性、客户端设备 | ├─ 步骤 4: 修复问题 | ├─ 步骤 5: 关闭调试 | └─ uuid_debug_media <uuid> both off | └─ 验证修复 └─ 重新测试呼叫
📚 相关文档
💡 最佳实践
快速定位问题 : 使用 show channels 快速找到 UUID
双向调试 : 优先使用 both 查看完整媒体流
及时关闭调试 : 避免日志量过大
防火墙检查 : 确保 RTP 端口范围开放
编解码器协商 : 优先使用标准编解码器(PCMU/PCMA/OPUS)
抓包分析 : 复杂问题使用 Wireshark 深入分析
🎯 常用命令速查 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 show channels show channels | grep 1001 uuid_dump <uuid> uuid_debug_media <uuid> both on uuid_debug_media <uuid> read on uuid_debug_media <uuid> write on uuid_debug_media <uuid> both off tail -f /usr/local/freeswitch/log/freeswitch.logconsole loglevel 7 show rtp uuid_getvar <uuid> read_codec uuid_getvar <uuid> write_codec eval ${rtp_port_min} eval ${rtp_port_max}
文档版本 : v1.0
最后更新 : 2026-01-29
维护者 : FreeSWITCH 运维团队