Open lucasjinreal opened 1 year ago
给下具体 rust 版本及不指定报的错误,我用 1.69.0-nightly 本地编译测试没问题
指定报错 403 跟这些加的 header 没关系
@rookie0 很奇怪,我换了两台电脑了,都是i这个问题,而且是runtime panic, 就是在这个方法内,其他都无问题
rustc --version
rustc 1.67.0 (fc594f156 2023-01-24)
panicked at 'called `Result::unwrap()` on an `Err` value: Protocol(InvalidHeader("sec-websocket-key"))'
很奇怪啊,我刚才编译了一下git代码,为啥有时候他会报这个错,有时候不会?
我加了一下header,然后就是403的错误:
// let req = Request::builder()
// .method(Method::GET)
// .uri(format!(
// "wss://hq.sinajs.cn/wskt?list={}",
// fmt_quote_symbols(symbols)
// ))
// // .header(header::ORIGIN, HeaderValue::from_static(PORTAL))
// .header(header::CONNECTION, "Upgrade")
// .header(header::UPGRADE, "websocket")
// .header("Sec-WebSocket-Version", "13")
// .header(header::HOST, HeaderValue::from_static(PORTAL))
// .header("Sec-WebSocket-Key", tungstenite::handshake::client::generate_key())
// .body(())
// .unwrap();
let req = Request::builder()
.method(Method::GET)
.uri(format!(
"wss://hq.sinajs.cn/wskt?list={}",
fmt_quote_symbols(symbols)
))
.header(header::ORIGIN, HeaderValue::from_static(PORTAL))
.body(())
.unwrap();
是我缺少了什么配置么
403 是因为用的 header 不对,应该是 origin
InvalidHeader("sec-websocket-key")
的问题 macos 未复现,不确定是否是 tungstenite
这个库不支持 windows 平台,你可以从这方面跟下
@rookie0 我mac下测试了也同样报错。 rust 是stable的最新版。
btw, 我是mac M1 pro
@rookie0 你clone一个git的不更改版本,编译一下看看么,我在公司电脑编译你的代码没有问题(windows), 在家用windows mac都会又那个runtime panic,缺少header。
是因为vpn?》??
这个问题让人丈二和尚摸不到头脑啊,
貌似最新的rust版本,不这么指定回报header错误,制定了也会报错:
Any idea?