Debian 12 安装 Janus 1.4.3 指南

在 Debian 12 上源码编译安装 Janus 1.4.3,覆盖依赖与 Lua 环境坑、configure/make/make configs 编译链、最小配置、systemd 托管与 HTTP API 全链路连通性实测。

JanusJanusWebRTC流媒体2026/10/26

Debian 12 安装 Janus 1.4.3 指南

目标:在一台干净的 Debian 12(bookworm)服务器上,从官方源码构建并安装 Janus 1.4.3(全称 janus-gateway,Meetecho 出品的开源 WebRTC SFU 流媒体网关),完成最小配置与 systemd 托管,最终通过 curl 对 HTTP REST API 做全链路连通性实测,得到一个可直接驱动的 WebRTC 服务器。组件定位与选型对比见《Janus 1.4.3 介绍与选型指南》。

一、部署目标与环境说明

项目值
目标系统Debian 12 (bookworm) x86_64
Janus 版本1.4.3(1.x multistream 主线最新稳定版)
编译器gcc (Debian 12.2.0-14+deb12u1) 12.2.0
安装前缀/opt/janus
托管方式systemd(janus.service)
实测日期2026-10-26

⚠️ 防同名混淆:本系列文档讲的 Janus 是 meetecho/janus-gateway(WebRTC SFU 网关),与图数据库 JanusGraph(平台已有《JanusGraph》专栏)毫无关系,选型检索时注意区分。

为什么不用 apt install janus?Debian 12 官方仓库里的 janus 包停留在旧版本(实测回显):

$ apt-cache policy janus
janus:
  Installed: (none)
  Candidate: 1.1.2-1
  Version table:
     1.1.2-1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages

1.1.2 距今已落后多个大版本,且仓库包不带 multistream 主线的最新修复。因此本文采用官方 README 推荐的源码编译路径,安装到独立前缀 /opt/janus,不污染系统目录,升级与卸载都干净。

二、前置依赖安装

Janus 是 C 项目,构建期需要编译工具链 + 一组多媒体/网络库的开发头文件,运行期则只需要这些库的 so 文件。先更新索引并安装工具链:

apt update
apt install -y build-essential pkg-config automake libtool libtool-bin \
    autotools-dev gengetopt git

再装库依赖(全部来自 Debian 官方仓库,无需第三方源):

apt install -y \
    libglib2.0-dev libjansson-dev libnice-dev libssl-dev libsrtp2-dev \
    libmicrohttpd-dev libwebsockets-dev libusrsctp-dev libsofia-sip-ua-dev \
    libopus-dev libogg-dev libcurl4-openssl-dev libconfig-dev \
    liblua5.3-dev

各库与 Janus 功能的对应关系(编译选项缺什么就少什么功能):

库作用缺失后果
libglib2.0-devGLib 事件循环/哈希表等基础数据结构无法编译
libjansson-devJSON 编解码(API 消息全靠它)无法编译
libconfig-dev解析 .jcfg 配置文件格式无法编译
libnice-devICE/STUN/TURN 协商(libnice)无法编译
libssl-devDTLS 握手与证书(OpenSSL)无法编译
libsrtp2-devSRTP 媒体流加解密无法编译
libmicrohttpd-devREST (HTTP/HTTPS) transportHTTP API 不可用
libwebsockets-devWebSockets transportWS API 不可用
libusrsctp-devDataChannels(DataChannel 通道)DataChannel 功能缺失
libsofia-sip-ua-devSIP 协议栈SIP 插件缺失
libopus-dev / libogg-devOpus 音频与 Ogg 封装录制/回放类功能缺失
libcurl4-openssl-devTURN REST API 客户端TURN REST 鉴权不可用
liblua5.3-devLua 解释器插件Lua 插件缺失

坑 1:Debian 12 的 Lua pkg-config 文件名不叫 lua.pc。 Janus 的 configure 脚本用 pkg-config --exists lua 探测 Lua,但 Debian 的 liblua5.3-dev 只提供 lua5.3.pc,直接 configure 会把 Lua 插件判为 no。先补一个符号链接:

ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/lua5.3.pc /usr/local/share/pkgconfig/lua.pc

验证(实测回显):

$ pkg-config --modversion lua
5.3.6

三、获取源码

从 GitHub 拉取 v1.4.3 的发布标签(两种等价方式,任选其一)。

方式 A:git clone + 切标签:

cd /usr/local/src
git clone https://github.com/meetecho/janus-gateway.git
cd janus-gateway
git checkout v1.4.3

方式 B:直接下载 release 压缩包(更快,无需 git 历史,实测采用此方式):

cd /usr/local/src
curl -L -o janus-1.4.3.tar.gz https://codeload.github.com/meetecho/janus-gateway/tar.gz/refs/tags/v1.4.3
tar xzf janus-1.4.3.tar.gz
cd janus-gateway-1.4.3

仓库检出的源码不含 configure 脚本,需要先用 autotools 生成(实测回显无报错即通过):

autoreconf -i

注意:如果 sh autoreconf -i 报 cannot open autoreconf 之类的错,多半是 shell 别名/环境问题,直接用 bash -c 'autoreconf -i' 或退出 su 环境后重试即可。

四、configure 与编译

坑 2:Lua 插件默认不编译。 必须显式加 --enable-plugin-lua,否则 configure 不会构建 libjanus_lua.so。配置命令:

./configure --prefix=/opt/janus --enable-plugin-lua

configure 结束时会打印一份能力清单,这是判断「哪些功能被编进来了」的权威依据(实测回显):

Compiler:                  gcc
libsrtp version:           2.x
SSL/crypto library:        OpenSSL
DTLS set-timeout:          not available
Mutex implementation:      GMutex (native futex on Linux)
DataChannels support:      yes
Recordings post-processor: no
TURN REST API client:      yes
Doxygen documentation:     no
Transports:
    REST (HTTP/HTTPS):     yes
    WebSockets:            yes
    RabbitMQ:              no
    MQTT:                  no
    Unix Sockets:          yes
    Nanomsg:               no
Plugins:
    Echo Test:             yes
    Streaming:             yes
    Video Call:            yes
    SIP Gateway:           yes
    NoSIP (RTP Bridge):    yes
    Audio Bridge:          yes
    Video Room:            yes
    Record&Play:           yes
    Text Room:             yes
    Lua Interpreter:       yes
    Duktape Interpreter:   no
Event handlers:
    Sample event handler:  yes
    WebSocket ev. handler: yes
    RabbitMQ event handler:no
    MQTT event handler:    no
    Nanomsg event handler: no
    GELF event handler:    yes
External loggers:
    JSON file logger:      no
JavaScript modules:        no

If this configuration is ok for you, do a 'make' to start building Janus. A 'make install' will install Janus and its plugins to the specified prefix. Finally, a 'make configs' will install some sample configuration files too (something you'll only want to do the first time, though).

RabbitMQ/MQTT/Nanomsg 等 transports 与 Duktape 插件默认 no(Debian 仓库未提供对应开发库,需自行编译上游库后才可选配);Web 生产部署常用的 REST + WebSockets 两条 transport 与全部核心插件在本清单中均为 yes。

接着编译并安装(-j 后接核数):

make -j$(nproc)
make install
make configs

三条命令的分工:make 编译出 janus 主程序与插件;make install 安装到 /opt/janus;make configs 只在第一次安装时需要执行——它把 30 余个 .sample 样例配置复制为实际生效的 .jcfg 文件,重复执行会用样例覆盖你的手工配置。

五、安装结果与目录结构

安装完成后 /opt/janus 结构如下:

/opt/janus
├── bin/                  # janus 主程序与 janus-cfgconv 配置转换工具
│   ├── janus
│   └── janus-cfgconv
├── etc/janus/            # 配置文件(make configs 生成)
├── lib/janus/
│   ├── loggers/          # 外部日志插件
│   ├── plugins/          # 业务插件(libjanus_echotest.so 等)
│   └── transports/       # 接入层(libjanus_http.so / libjanus_websockets.so 等)
└── share/janus/
    ├── lua/              # Lua 插件的脚本目录
    └── html/demos/       # 官方 demo 页面静态文件

版本确认(实测回显):

$ /opt/janus/bin/janus -V
Janus version: 1403 (1.4.3)
Janus commit: not-a-git-repo
Compiled on:  Mon Oct 26 05:43:19 UTC 2026

六、最小配置

make configs 在 /opt/janus/etc/janus/ 生成 17 个生效的 .jcfg 文件(外加同名 .sample 备份),覆盖主配置、各 transport、各插件与事件处理器。最小可用部署其实只需要理解三个文件,其余保持默认即可。

6.1 主配置 janus.jcfg

general 段声明各资源目录与日志行为,安装路径由 configure 的 --prefix 自动写入,无需手改:

general: {
	configs_folder = "/opt/janus/etc/janus"			# Configuration files folder
	plugins_folder = "/opt/janus/lib/janus/plugins"			# Plugins folder
	transports_folder = "/opt/janus/lib/janus/transports"	# Transports folder
	events_folder = "/opt/janus/lib/janus/events"			# Event handlers folder
	loggers_folder = "/opt/janus/lib/janus/loggers"			# External loggers folder

	debug_level = 4							# Debug/logging level, valid values are 0-7
}

media 段的 RTP 端口范围默认 20000-40000(注释态即默认值):

	#rtp_port_range = "20000-40000"

生产防火墙务必放行该 UDP 段,媒体流走的就是这些端口;API 端口 8088/8188 只是信令通道,不传媒体。

nat 段决定 ICE 行为。Janus 启动时自动选一块网卡 IP 作为 local IP,公网部署必须在 nat 段配置 turn_server/stun_server 或 nat_1_1_mapping,否则公网用户无法打洞。本机内网部署时启动日志会给出明确警告(见第八节)。

6.2 HTTP transport:janus.transport.http.jcfg

REST API 的开关与端口都在这里,默认即已启用:

general: {
	json = "compact"				# Whether the JSON messages should be indented (pretty),
									# plain (no indentation) or compact (no indentation and no spaces)
	base_path = "/janus"			# Base path to bind to in the web server (plain HTTP only)
	http = true						# Whether to enable the plain HTTP interface
	port = 8088						# Web server HTTP port
	https = false					# Whether to enable HTTPS (default=false)
}
admin: {
	admin_base_path = "/admin"			# Base path to bind to in the admin/monitor web server (plain HTTP only)
	admin_http = false					# Whether to enable the plain HTTP interface
	admin_port = 7088					# Admin/monitor web server HTTP port
}

要点:API 路径是 http://<IP>:8088/janus;admin_http 默认 false——Admin/monitor API(7088)能力更强(能查会话句柄明细),对外开放前想清楚,内网调试再打开。

6.3 WebSockets transport:janus.transport.websockets.jcfg

general: {
	json = "compact"				# Whether the JSON messages should be indented (pretty),
	ws = true						# Whether to enable the WebSockets API
	wss = false						# Whether to enable secure WebSockets
}

ws = true 默认启用,监听 8188。浏览器端长连接推荐走 WS(HTTP 版需要长轮询 event),二者 API 语义完全一致。

配置文件的语法校验不必靠肉眼,Janus 自带 janus-cfgconv 可以离线解析 .jcfg:

/opt/janus/bin/janus-cfgconv /opt/janus/etc/janus/janus.jcfg

七、systemd 托管

写单元文件 /etc/systemd/system/janus.service:

[Unit]
Description=Janus WebRTC Server
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/opt/janus/bin/janus --configs-folder=/opt/janus/etc/janus
User=root
Restart=on-failure
RestartSec=5
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

两点说明:

  • ExecStart 用 --configs-folder 而不是 --config。--config 参数接受的是「配置文件名」(相对于 configs-folder 的文件名),传绝对路径会导致启动失败;让 Janus 从指定目录加载全部默认配置用 --configs-folder 最稳妥。
  • LimitNOFILE=65536 对应官方 FAQ 对 ulimit 的要求:WebRTC 服务器每路连接都要消耗文件描述符,默认 1024 远远不够。

启用并启动:

systemctl daemon-reload
systemctl enable janus
systemctl start janus

状态确认(实测回显):

$ systemctl is-active janus
active
$ systemctl is-enabled janus
enabled

systemctl status janus(节选):

● janus.service - Janus WebRTC Server
     Loaded: loaded (/etc/systemd/system/janus.service; enabled; preset: enabled)
     Active: active (running) since Mon 2026-10-26 06:12:55 UTC; 20s ago
   Main PID: 3884 (janus)
      Tasks: 27 (limit: 2932)
     Memory: 18.8M
        CPU: 180ms

Oct 26 06:12:55 janus-host janus[3884]: [WARN] The 'janus.transport.pfunix' plugin could not be initialized
Oct 26 06:12:55 janus-host janus[3884]: Loading transport plugin 'libjanus_websockets.so'...
Oct 26 06:12:55 janus-host janus[3884]: libwebsockets logging: 0
Oct 26 06:12:55 janus-host janus[3884]: Websockets server started (port 8188)...
Oct 26 06:12:55 janus-host janus[3884]: JANUS WebSockets transport plugin initialized!
Oct 26 06:12:55 janus-host janus[3884]: Loading transport plugin 'libjanus_http.so'...

pfunix(Unix Socket transport)的 WARN 属正常现象:它的 .jcfg 默认未启用该监听,Janus 加载后放弃初始化,不影响其他功能。

监听端口确认(实测回显):

$ ss -ltn | grep -E ":(8088|8188)"
LISTEN 0      4096               *:8088             *:*
LISTEN 0      4096               *:8188             *:*

排障提示:若 systemctl start janus 长时间无响应,先用 systemctl list-jobs 查看是否有作业卡在 waiting 队列里(开机链路上的某个依赖单元没起来,新作业会一直排队),确认后 systemctl cancel 清掉积压作业再单独 start 目标服务。

八、启动日志解读

Janus 前台启动日志(等价于 journalctl -u janus 的内容)关键行(实测回显):

---------------------------------------------------
  Starting Meetecho Janus (WebRTC Server) v1.4.3
---------------------------------------------------

Checking command line arguments...
Debug/log level is 4
Debug/log timestamps are disabled
Debug/log colors are enabled
Adding 'vmnet' to the ICE ignore list...
Using 10.89.59.2 as local IP...
Token based authentication disabled
Initializing recorder code
Initializing ICE stuff (Full mode, ICE-TCP candidates disabled, half-trickle, IPv6 support disabled)
TURN REST API backend: (disabled)
[WARN] Janus is deployed on a private address (10.89.59.2) but you didn't specify any STUN server! Expect trouble if this is supposed to work over the internet and not just in a LAN...
Crypto: OpenSSL >= 1.1.0
No cert/key specified, autogenerating some...
Fingerprint of our certificate: 2A:4B:AB:5A:C6:FD:64:2D:DA:45:D5:CA:75:1C:F4:8F:DD:C4:A5:64:BD:3B:CD:DC:52:D1:9B:A2:EB:BA:48:BD
Event handlers support disabled
Plugins folder: /opt/janus/lib/janus/plugins
Loading plugin 'libjanus_videoroom.so'...
Joining Janus requests handler thread
Sessions watchdog started
JANUS VideoRoom plugin initialized!

逐行要点:

  • Using 10.89.59.2 as local IP:Janus 自动把第一块网卡的地址作为 ICE local IP;多网卡机器必须在 janus.jcfg 的 general 段用 interface = "eth0" 或 ip = "x.x.x.x" 显式指定。
  • Token based authentication disabled / apisecret:默认不鉴权!8088/8188 暴露在公网前必须在 janus.jcfg 的 general 段配置 apisecret 或启用 token 鉴权。
  • No cert/key specified, autogenerating some...:没配证书时 Janus 自签一把并打印 DTLS 指纹,本机/内网测试够用;生产应在 certificates 段配置正规证书。
  • private address + 无 STUN 的 WARN:内网部署的预期行为;公网部署需配置 STUN/TURN,否则远端用户收不到媒体。
  • half-trickle:默认非完全 trickle ICE,候选随 answer 一次性带出。

九、HTTP API 连通性实测

一切就绪的最终判据是驱动一次完整 API 会话。Janus 的 API 模型:create 建 session → attach 挂插件得到 handle → message 发业务请求(带 JSEP SDP)→ 长轮询取 event → keepalive 保活 → destroy 销毁。

9.1 创建会话

curl -s -X POST http://127.0.0.1:8088/janus -H "Content-Type: application/json" \
     -d '{"janus":"create","transaction":"b1create000001"}'

实测回显:

{"janus":"success","transaction":"b1create000001","data":{"id":7699435502130401}}

data.id 就是 session id,后续所有请求都拼在 /janus/<session_id> 下。transaction 是客户端生成的 16 位以内随机串,用于应答匹配。

9.2 挂载 echotest 插件

curl -s -X POST http://127.0.0.1:8088/janus/7699435502130401 -H "Content-Type: application/json" \
     -d '{"janus":"attach","transaction":"b1attch000001","plugin":"janus.plugin.echotest"}'

实测回显:

{"janus":"success","session_id":7699435502130401,"transaction":"b1attch000001","data":{"id":4625299469112602}}

得到 handle id 4625299469112602。echotest 是官方「回声测试」插件:把收到的音视频原样推回给客户端,专门用于链路自检。

9.3 发送业务消息(携带 SDP offer)

把请求体写成文件 /tmp/offer.json(SDP 内容 \r\n 转义为 JSON 字符串):

{"janus":"message","transaction":"b1msg000000001","body":{"audio":true,"video":true},"jsep":{"type":"offer","sdp":"v=0\r\no=- 1761000000 2 IN IP4 127.0.0.1\r\ns=janus-b1\r\nt=0 0\r\nm=audio 7010 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 127.0.0.1\r\na=ice-ufrag:abcd\r\na=ice-pwd:abcd1234efgh5678\r\na=fingerprint:sha-256 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF\r\na=setup:actpass\r\na=mid:audio\r\na=sendonly\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\n"}}

发送:

curl -s -X POST http://127.0.0.1:8088/janus/7699435502130401/4625299469112602 \
     -H "Content-Type: application/json" -d @/tmp/offer.json

实测回显(消息已受理,异步处理):

{"janus":"ack","session_id":7699435502130401,"transaction":"b1msg000000001","hint":"I'm taking my time!"}

9.4 长轮询取事件(SDP answer)

curl -s "http://127.0.0.1:8088/janus/7699435502130401?maxev=1"

实测回显——插件返回了带完整 SDP answer 的 event(ice-ufrag、DTLS 指纹、host candidate 都是 Janus 现场生成的真实值):

{"janus":"event","session_id":7699435502130401,"transaction":"b1msg000000001","sender":4625299469112602,"plugindata":{"plugin":"janus.plugin.echotest","data":{"echotest":"event","result":"ok"}},"jsep":{"type":"answer","sdp":"v=0\r\no=- 1761000000 2 IN IP4 10.89.59.3\r\ns=janus-b1\r\nt=0 0\r\na=group:BUNDLE audio\r\na=ice-options:trickle\r\na=fingerprint:sha-256 C3:EF:AB:2E:6F:46:02:57:77:F8:FB:CD:BC:4D:0B:AA:68:11:88:7D:25:B0:70:1F:67:1F:DB:D7:2F:2F:99:17\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS *\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 10.89.59.3\r\na=recvonly\r\na=mid:audio\r\na=rtcp-mux\r\na=ice-ufrag:KL6e\r\na=ice-pwd:Gl9jOa2PWmJxplroUhW7Iz\r\na=ice-options:trickle\r\na=setup:active\r\na=rtpmap:111 opus/48000/2\r\na=msid:janus janusaudio\r\na=ssrc:3813737423 cname:janus\r\na=candidate:1 1 udp 2015363327 10.89.59.3 46062 typ host\r\na=end-of-candidates\r\n"}}

1.x 与 0.x 的关键语义差异:multistream 主线(1.x)中 echotest 由客户端先发 offer、插件回 answer;网上大量旧教程(基于 0.x)写的是插件先发 offer——拿着旧教程的时序对 1.4.3 发请求会一直收不到 jsep,不是故障,是版本差异。

9.5 keepalive 与 destroy

curl -s -X POST http://127.0.0.1:8088/janus/7699435502130401 -H "Content-Type: application/json" \
     -d '{"janus":"keepalive","transaction":"b1keep0000001"}'
{"janus":"ack","session_id":7699435502130401,"transaction":"b1keep0000001"}
curl -s -X POST http://127.0.0.1:8088/janus/7699435502130401 -H "Content-Type: application/json" \
     -d '{"janus":"destroy","transaction":"b1dstry000001"}'
{"janus":"success","session_id":7699435502130401,"transaction":"b1dstry000001"}

对已销毁的会话再发任意请求,会得到结构化错误(实测回显):

{"janus":"error","session_id":7699435502130401,"transaction":"b1gone0000001","error":{"code":458,"reason":"No such session 7699435502130401"}}

至此 create → attach → message → answer → keepalive → destroy 全链路闭环,安装有效性验证完成。

十、Demo 页面说明

make install 顺带安装了官方 demo 的静态文件(实测目录清单):

/opt/janus/share/janus/html/demos/
├── index.html            # demo 入口导航
├── janus.js / settings.js # 官方 JS API 封装与全局配置
├── echotest.html/.js     # 回声测试
├── streaming.html/.js    # 流播放
├── videoroom.html/.js    # 视频房间
├── audiobridge.html/.js  # 音频混音房间
├── videocall.html/.js    # 一对一通话
├── sip.html/.js          # SIP 网关
├── textroom.html/.js     # 聊天室
├── recordplay.html/.js   # 录制回放
└── ...(screensharing / nosip / multiopus / virtualbg 等)

关键认知:8088 端口不托管这些页面。 Janus 的 HTTP transport 只在 /janus 基路径上提供 JSON API,用浏览器直接访问 http://<IP>:8088 不会有任何页面。demo 页面需要用任意静态文件服务器(nginx、甚至 python3 -m http.server)把 /opt/janus/share/janus/html/demos/ 发布出去,并修改 settings.js 里的 server 地址指向 ws://<IP>:8188(或 http://<IP>:8088/janus),浏览器端才能连上。

不部署 demo 页也不影响 API 验证——本文第九节的 curl 全链路就是最小自检手段。

十一、常见问题与排障实录

Q1:configure 后能力清单里 Lua Interpreter 是 no? 两个独立原因,都要检查:

  1. 没加 --enable-plugin-lua(默认 no);
  2. Debian 只有 lua5.3.pc,configure 找不到 lua.pc——按第二节补符号链接后重新 configure。

Q2:Lua 插件启动报 module 'json' not found? 实测实录:Lua 插件初始化时加载 /opt/janus/share/janus/lua/echotest.lua,脚本第 6 行 require "json"。Debian 的 lua-cjson 包提供的模块名是 cjson 而不是 json,装 lua-cjson 并不能解决。Janus 会把自己的 lua 脚本目录加进 package.path,因此最直接的修法是把纯 Lua 实现的 dkjson 放进去顶名:

curl -L -o /opt/janus/share/janus/lua/json.lua https://raw.githubusercontent.com/LuaDist/dkjson/master/dkjson.lua

真实报错回显(修复前):

[ERR] [plugins/janus_lua.c:janus_lua_init:1418] Error loading Lua script /opt/janus/share/janus/lua/echotest.lua: /opt/janus/share/janus/lua/echotest.lua:6: module 'json' not found:
        no field package.preload['json']
        no file '/usr/local/share/lua/5.3/json.lua'
        no file '/usr/local/share/lua/5.3/json/init.lua'
        no file '/usr/local/lib/lua/5.3/json.lua'

修复后重启,日志中应看到(实测回显):

[echotest.lua] Loading...
[echotest.lua] Loaded
[echotest.lua] Initializing...
[echotest.lua] Initialized
Janus Lua plugin initialized!

部分脚本还会用到 term.colors(终端着色),缺了会报 module 'term.colors' not found,补装 apt install lua-term 即可(模块落地在 /usr/lib/x86_64-linux-gnu/lua/5.3/term)。

Q3:session 用着用着报 458 No such session? Janus 的 session 有 60 秒 keepalive 超时:客户端必须周期性发 keepalive(或任何合法请求)续命,超时后 watchdog 直接回收。服务端日志(实测回显):

Timeout expired for session 213764637636828...
Destroying session 213764637636828; 0x79eddc000d40

对已回收会话的后续请求一律返回 code 458(见 9.5 节)。长轮询客户端把轮询间隔压到 30 秒以内即可,或改用 WebSockets(连接本身可当 keepalive 用,配合 janus.js 无需手工续命)。

Q4:systemctl start janus 一直卡住不返回? 见第七节排障提示:systemctl list-jobs 查积压,systemctl cancel 清队列后重试。

Q5:日志警告 "Janus is deployed on a private address ... didn't specify any STUN server"? 内网部署可忽略;对公网提供服务时按第六节 nat 段说明配置 STUN/TURN 或 nat_1_1_mapping。

十二、验收清单

  • /opt/janus/bin/janus -V 显示 Janus version: 1403 (1.4.3)
  • configure 能力清单:REST (HTTP/HTTPS)、WebSockets 均为 yes,所需插件均为 yes
  • systemctl is-active janus → active,is-enabled → enabled
  • ss -ltn 可见 8088 与 8188 监听
  • curl 全链路:create / attach / message / answer / keepalive / destroy 全部成功
  • 防火墙已放行 8088/tcp、8188/tcp 与 20000-40000/udp(生产必做)
  • 公网部署:apisecret/token 鉴权与证书(certificates 段)已配置

后续配置项逐项详解见《Janus 1.4.3 配置参数详解》,命令行与 API 命令族速查见《Janus 1.4.3 常用 CLI 命令与工具详解》,容器化部署见《Janus 1.4.3 Docker Compose 部署指南》。


本文所有命令与回显均在 Debian 12 (bookworm) + Janus 1.4.3 实测环境采集(2026-10-26),输出为真实回显照录,个别与主机相关的内容(IP、PID、时间戳)以你的环境为准。