已解决:Ubuntu系统下Darkice无法连接Shoutcast服务器问题排查
Darkice连接Shoutcast服务器无流输出故障解决
初始配置
我在Ubuntu系统中使用Darkice客户端尝试对接Shoutcast服务器,所用配置如下:
# 直播流会话通用配置 [general] duration = 0 # 编码时长,单位秒,0表示永久推流 bufferSecs = 10 # 内部缓冲大小,单位秒 reconnect = yes # 断开连接后自动重连 realtime = no # 不使用POSIX实时优先级运行编码器 rtprio = 3 # 实时线程调度优先级 # 音频输入配置 [input] device = hw:CARD=PCH,DEV=0 sampleRate = 44100 # 采样率,可选11025、22050、44100 bitsPerSample = 16 # 采样位深,推荐16 channel = 2 # 声道数,1=单声道,2=立体声 # Shoutcast服务器连接配置 [shoutcast-0] bitrateMode = cbr format = mp3 bitrate = 96 quality = 1.0 server = xxxxxxxxxxxxxxx port = 8020 password = xxxxxxxxxxxxxxx name = Radio website url = https://www.mywebsite.it genre = live public = no
启动操作与故障现象
使用如下命令启动Darkice:
darkice -v 10 -c /etc/darkice-shoutcast.cfg
执行后仅输出如下日志,无明确报错,但服务器端没有收到直播流。同环境下使用BUTT工具可以正常连接该Shoutcast服务器,尝试将端口从8020替换为8021测试,仍无法成功连接。
启动日志内容:
DarkIce 1.4 live audio streamer, http://code.google.com/p/darkice/ Copyright (c) 2000-2007, Tyrell Hungary, http://tyrell.hu/ Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz This is free software, and you are welcome to redistribute it under the terms of The GNU General Public License version 3 or any later version. Using config file: /etc/darkice-shoutcast.cfg 18-May-2021 12:02:28 Using ALSA DSP input device: hw:CARD=PCH,DEV=0 18-May-2021 12:02:28 buffer size: 1764000 18-May-2021 12:02:28 encoding 18-May-2021 12:02:28 MultiThreadedConnector :: transfer, bytes 0 18-May-2021 12:02:28 MultiThreadedConnector :: ThreadData :: threadFunction, was (thread, priority, type): 0x5568a502c010 0 SCHED_OTHER 18-May-2021 12:02:28 MultiThreadedConnector :: ThreadData :: threadFunction, now is (thread, priority, type): 0x5568a502c010 0 SCHED_OTHER
排查过程
使用tcpdump抓包分析交互内容,发现服务器返回包中存在invalid password相关报错:
: Flags [P.], cksum 0xc379 (correct), seq 1:19, ack 3090, win 294, options [nop,nop,TS val 3348978428 ecr 531576376], length 18 E..F1O@.1.3'.}.......T.Jq.k.D......&.y..... ..Z...68Invalid Passwor
故障原因与修复方案
Darkice的配置解析逻辑对密码字段的格式要求严格,原配置中password字段等号前后的空格会被识别为密码的一部分,导致校验失败。
删除密码行等号前后的空格即可解决问题,修改后的配置如下:
[shoutcast-0] bitrateMode = cbr format = mp3 bitrate = 96 quality = 1.0 server = xxxxxxxxxxxxxxx port = 8020 password=xxxxxxxxxxxxxxx name = Radio website url = https://www.mywebsite.it genre = live public = no
内容的提问来源于stack exchange,提问作者Miro Barsocchi
相关产品推荐
相关产品推荐

