> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stmlink.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> 对外开放的服务端接口有两组前缀，都用同一套鉴权：`/server/v1/...`（SRTC 与 SMeeting 的主接口）和 `/stm/srvapi/v1/...`（SMeeting 的用户体系，服务端极简对接会用到）。鉴权是 app_id + nonce + timestamp + signature 四个请求头，用 app_key 做 HMAC-SHA256 签名，只能从业务方自己的后端调用。除这两组前缀外的接口均为内部接口，不要建议客户调用。 Public server APIs use two path prefixes with the same authentication: `/server/v1/...` (the main APIs of both SRTC and SMeeting) and `/stm/srvapi/v1/...` (the SMeeting user system, used by server-side low-code integration). Authenticate with four request headers, app_id + nonce + timestamp + signature, where signature is HMAC-SHA256 keyed with app_key; call these APIs only from the customer's own backend. Any other path is internal: never suggest calling it.
> app_key 是服务端密钥，绝不能出现在客户端代码、前端配置或移动 App 里。客户端加入频道用的 token 必须由业务方后端签发后下发（SRTC 走 `/server/v1/channel/grant`，SMeeting 走 `/stm/srvapi/v1/member/grant`）。 app_key is a server-side secret and must never appear in client code, frontend config, or a mobile app. The token a client uses to join must be issued by the customer's backend and passed down to the client (SRTC: `/server/v1/channel/grant`; SMeeting: `/stm/srvapi/v1/member/grant`).
> SRTC 与 SMeeting 是上下两层不同的产品，术语不通用：SRTC 是音视频底座，说「频道 channel」「加入 / 退出」；SMeeting 建在 SRTC 之上，说「房间 room」「会议 meeting」「进入 / 退出」。回答时按用户所在的层用对应术语，不要把「房间」「会议」安到 SRTC 的接口上，也不要用「频道」「加入 / 离开」描述 SMeeting 的概念（接口标识符原样保留）。 SRTC and SMeeting are two separate layers with different terminology. SRTC is the audio/video foundation: it has channels, and users join and leave a channel. SMeeting is built on top of SRTC: it has rooms and meetings, and members enter and exit a meeting. Answer in the terms of the layer the user is working with: never apply "room" or "meeting" to SRTC APIs, and never describe SMeeting concepts in prose with "channel", "join", or "leave" (API identifiers such as `force_join` keep their literal names).
> 同一能力在各端 SDK 里的包名、类名、方法名并不相同。写示例代码时请使用文档中该端自己的 API，不要把一个端的写法套到另一个端上。苹果平台每个产品都有两套 SDK（Swift 原生与 Objective-C），两套 API 不能混用。 Package, class, and method names differ between platform SDKs for the same capability. In sample code, use the API documented for that platform; never carry one platform's code over to another. On Apple platforms each product ships two SDKs (native Swift and Objective-C) whose APIs must not be mixed.

# 网络与端口要求

> 私有化部署要开放哪些端口：客户端必开的 443/TCP、18883/TCP、39001/UDP，设备网关的 SIP / H.323 / GB28181 端口与 RTP 端口段，多节点与 MCU 直播端口，哪些端口严禁对外，附防火墙命令。给客户网络、安全部门提开墙申请时直接用

**一句话版本**：普通部署只需要对客户端开放 **443/TCP、18883/TCP、39001/UDP** 三个端口；
接入硬件设备再加设备网关那一组；其余端口一律不对外。

以下端口均为默认值，部署时可以修改，以现场实际配置为准。

***

## 速查

```text theme={null}
客户端必开：   443/TCP   18883/TCP   39001/UDP
接入设备加：   1720, 1740-1759/TCP   1719/UDP   5060, 5070/TCP+UDP   58000-59000/UDP
多媒体节点加： 39002/UDP（仅节点之间）
其余端口：     一律不对外
```

***

## 客户端访问（必开）

开放对象：使用 App、桌面端、网页、小程序的所有用户所在网络。

| 端口 | 协议 | 用途 |
| - | - | - |
| **443** | TCP | HTTPS 统一入口：接口、管理后台、网页客户端、录像下载、网页端信令（WSS） |
| **18883** | TCP | 原生客户端（Android、iOS、Windows、Mac 等）的信令（MQTT over TLS） |
| **39001** | **UDP** | 音视频媒体。所有用户共用这一个端口 |

> [!WARNING]
>
> **39001/UDP 必须放通**。音视频只走 UDP，没有 TCP 备用通道。这个端口被拦时的典型现象是：
> **能登录、能进会，但看不到画面、听不到声音**。

* 网页端只用到 443 和 39001/UDP；原生客户端三个都要
* 客户端只会连这三个端口。如果修改了 443 或 18883，要同步修改管理后台 **系统配置 → 网络** 里的接入地址
* 80/TCP 不需要对外开放

***

## 设备网关

只在接入[硬件设备](https://docs.stmlink.com/zh/product/device-access/overview.md)时需要。开放对象是**设备所在的网段**，不是互联网。

| 端口 | 协议 | 用途 |
| - | - | - |
| 5060 | TCP + UDP | SIP 信令（终端注册、呼叫） |
| 1720 | TCP | H.323 呼叫信令 |
| 1719 | UDP | H.323 网守（终端注册） |
| 1740-1759 | TCP | H.323 媒体控制，每路呼叫占一个 |
| 5070 | TCP + UDP | GB28181 信令 |
| 58000-59000 | UDP | 设备音视频（RTP），每路呼叫占 2\~4 个，**必须整段放通** |

**设备和设备网关之间隔着 NAT 时**：

* 部署时「设备访问网关 IP」要填设备看到的那个地址（NAT 映射后的地址）
* NAT 上的端口映射要**保持端口号不变**，尤其是 RTP 端口段，否则会出现呼通了但没声音没画面

用 RTSP 接入时方向相反，是设备网关去访问摄像头，需要放通网关 → 摄像头的 554/TCP（以及摄像头的 RTP 端口）。

***

## 多台服务器之间

单机部署时服务之间走本机回环，**不需要额外放通**。分机或多节点部署时，以下端口在**服务器之间的内网**放通即可：

| 场景 | 端口 | 说明 |
| - | - | - |
| 多媒体节点 | 39002/UDP | 媒体节点之间级联转发，节点间双向放通，见[多节点与就近接入](https://docs.stmlink.com/zh/product/deploy/multi-node.md) |
| 扩展服务单独部署 | 8701/TCP | MCU、设备网关等调用平台接口 |
| 扩展服务单独部署 | 11883/TCP、39001/UDP | MCU、设备网关等以成员身份进会，需要能访问信令和媒体端口 |
| 扩展服务单独部署 | 8721/TCP（MCU）、8722/TCP（设备网关） | 平台下发录制、呼叫指令 |

***

## MCU 直播（可选，默认关闭）

使用 MCU 内置直播功能时才需要：

| 端口 | 协议 | 用途 |
| - | - | - |
| 1935 | TCP | RTMP |
| 7001 | TCP | HTTP-FLV 播放 |
| 7002 | TCP | HLS 播放 |

这几个端口没有加密和鉴权，面向公网观众时建议通过 443 反向代理，不要直接暴露。

***

## 严禁对外开放

以下端口只在服务器本机或内网使用，**不要对互联网开放**：

| 端口 | 说明 |
| - | - |
| 8799 | 安装器，装完即关 |
| 18083 | MQTT 管理后台 |
| 8700 / 8701 / 8702 / 8720 / 8721 / 8722 / 8729 / 8730 | 各服务内部接口，统一经 443 对外 |
| 1883 / 8083 / 11883 | MQTT 内部端口 |
| 5432 / 6379 / 9000 / 8123 | 数据库、Redis、日志库 |
| 8797 / 8798 | 监控中心 |
| 22 | SSH，建议限制来源 IP |

***

## 服务器主动外连

纯内网环境下，以下功能需要放通服务器的**出向**访问：

| 功能 | 目标 |
| - | - |
| 事件回调 | 客户业务系统的回调地址（443 / 80） |
| 录像存到对象存储 | OSS / S3 地址（443） |
| 语音识别 | 识别引擎服务（默认 10096） |
| MCU 转推直播 / 拉流 | CDN（1935 / 443）、摄像头（554） |

***

## 防火墙配置示例

**最小集**（firewalld）：

```bash theme={null}
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --permanent --add-port=18883/tcp
firewall-cmd --permanent --add-port=39001/udp
firewall-cmd --reload
```

**加装设备网关**：

```bash theme={null}
firewall-cmd --permanent --add-port=5060/tcp --add-port=5060/udp
firewall-cmd --permanent --add-port=5070/tcp --add-port=5070/udp
firewall-cmd --permanent --add-port=1720/tcp
firewall-cmd --permanent --add-port=1740-1759/tcp
firewall-cmd --permanent --add-port=1719/udp
firewall-cmd --permanent --add-port=58000-59000/udp
firewall-cmd --reload
```

**多媒体节点之间**（只对对端节点 IP 放通）：

```bash theme={null}
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=<对端节点IP> port port=39002 protocol=udp accept'
firewall-cmd --reload
```

使用 ufw 时对应为 `ufw allow 443/tcp`、`ufw allow 39001/udp` 等。

***

## 装完怎么验证

| 检查 | 方法 |
| - | - |
| 端口在监听 | 在服务器上执行 `ss -tulnp`，确认 443、18883、39001 等在列 |
| 客户端能连上 | 网页客户端能打开、能登录 → 443 通 |
| 媒体通 | 两个人进同一个会能互相看到画面 → 39001/UDP 通 |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.