Bug 描述
@eric8810/catcher-napi-ws 预编译 binary 没有 TLS 支持,所有 wss:// 连接立即失败。
根因
catcher-ws 的 Cargo.toml 中 tokio-tungstenite = "0.29" 没有启用任何 TLS feature。
tokio-tungstenite 默认只启用 connect + handshake,不包含 TLS。需要显式启用 native-tls 或 rustls-tls-* feature 才能支持 wss://。
代码中使用了 tokio_tungstenite::MaybeTlsStream 和 connect_async_with_config,在没有 TLS 编译支持时,MaybeTlsStream 退化为 plain TCP,wss:// URL 会直接报错。
影响
- 所有
wss:// WebSocket 连接
- 仅影响预编译 binary(本地
cargo build 也不含 TLS)
ws://(非加密)不受影响
修复
-
catcher-ws/Cargo.toml:
- 添加
[features],default = ["rustls-tls"]
rustls-tls = ["tokio-tungstenite/rustls-tls-webpki-roots"]
native-tls = ["tokio-tungstenite/native-tls"](备选)
tokio-tungstenite 改为 default-features = false,显式启用 connect + handshake
-
catcher-napi-ws/Cargo.toml:
catcher-ws 依赖显式加 features = ["rustls-tls"]
-
TLS 方案选择 rustls-tls-webpki-roots(与 catcher-http 的 rustls 方案一致),交叉编译友好。
验证
编译后可以看到 rustls、tokio-rustls 被正确引入为依赖(之前完全没有编译过)。
cargo check -p catcher-ws -p catcher-napi-ws
# 现在 rustls 会被编译进来
cargo test -p catcher-ws # 单元测试通过
Bug 描述
@eric8810/catcher-napi-ws预编译 binary 没有 TLS 支持,所有wss://连接立即失败。根因
catcher-ws的Cargo.toml中tokio-tungstenite = "0.29"没有启用任何 TLS feature。tokio-tungstenite默认只启用connect+handshake,不包含 TLS。需要显式启用native-tls或rustls-tls-*feature 才能支持wss://。代码中使用了
tokio_tungstenite::MaybeTlsStream和connect_async_with_config,在没有 TLS 编译支持时,MaybeTlsStream退化为 plain TCP,wss://URL 会直接报错。影响
wss://WebSocket 连接cargo build也不含 TLS)ws://(非加密)不受影响修复
catcher-ws/Cargo.toml:[features],default = ["rustls-tls"]rustls-tls = ["tokio-tungstenite/rustls-tls-webpki-roots"]native-tls = ["tokio-tungstenite/native-tls"](备选)tokio-tungstenite改为default-features = false,显式启用connect+handshakecatcher-napi-ws/Cargo.toml:catcher-ws依赖显式加features = ["rustls-tls"]TLS 方案选择
rustls-tls-webpki-roots(与catcher-http的 rustls 方案一致),交叉编译友好。验证
编译后可以看到
rustls、tokio-rustls被正确引入为依赖(之前完全没有编译过)。