Files
VibeCoding/webrtc_controller_flutter/lib/config/ice_servers.dart
tongtongstudio 6d729f38be fix(webrtc): 更新ICE服务器配置,新增备用TURN服务器并修复iOS模拟器连接问题
- 新增47.242.112.133的STUN/TURN服务器作为备用中继
- Flutter端添加turns: TLS中继,修复iOS模拟器无法获取relay候选的问题
- Web端同步添加新的ICE服务器配置
- 添加.gitignore忽略IDE配置文件
2026-07-31 22:19:09 +08:00

53 lines
2.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/// ICE 服务器配置。
///
/// 与可正常连接的 `webrtc_controller_ios`(原生 Swift 项目)保持一致:
/// 使用 `www.ttstd.com:3478` 作为 STUN/TURN 服务器。
///
/// 注意:旧配置曾误用 `175.178.213.60:3478`(错误凭据)及内网
/// `192.168.5.224:3478`(模拟器不可达),导致 iOS 模拟器下
/// `ICE Checking -> Failed`。已修正为与 iOS 原生项目相同的服务器。
/// ICE 服务器配置。
///
/// 与「被控端 Android」同一台 TURN 服务器175.178.213.60)、同一凭据
/// fanhuitong / Fan19961907..)。
///
/// **iOS 模拟器关键修复**
/// 明文 `turn:175.178.213.60:3478` 在 iOS 模拟器libwebrtc下不会发起
/// RELAY 分配请求,导致控制端本地候选缺失 `typ relay`,两端无公共中继可
/// 配对 → candidate-pair=0 → ICE FailedAndroid 真机/网页则正常)。
/// 改用 `turns:`TLS over TCP 5349模拟器能稳定拿到 relay 候选。
/// 同时保留 udp / tcp 明文项作为降级,以及 STUN 用于 srflx。
const List<Map<String, dynamic>> kIceServers = [
{'urls': 'stun:stun.l.google.com:19302'},
{'urls': 'stun:175.178.213.60:3478'},
{
// 首选TLS over TCPiOS 模拟器下能稳定分配 relay 候选。
'urls': 'turns:175.178.213.60:5349',
'username': 'fanhuitong',
'credential': 'Fan19961907..',
},
{
// 降级:明文 UDP/TCP。
'urls': 'turn:175.178.213.60:3478',
'username': 'fanhuitong',
'credential': 'Fan19961907..',
},
{
'urls': 'turn:175.178.213.60:3478?transport=tcp',
'username': 'fanhuitong',
'credential': 'Fan19961907..',
},
{'urls': 'stun:47.242.112.133:3478'},
{
'urls': 'turn:47.242.112.133:3478',
'username': 'ttstd',
'credential': 'fanhuitong',
},
];
/// 信令 WebSocket 默认地址。
const String kDefaultSignalServer = 'wss://www.ttstd.com/signal';
/// DataChannel 标签,控制端与被控端需一致。
const String kDataChannelLabel = 'control_channel';