Giter VIP home page Giter VIP logo

panicked at 'called `Result::unwrap()` on an `Err` value: Http(Response { status: 403, version: HTTP/1.1, headers: {"content-length": "9"}, body: Some([70, 111, 114, 98, 105, 100, 100, 101, 110]) })', about rains HOT 6 OPEN

rookie0 avatar rookie0 commented on August 23, 2024
panicked at 'called `Result::unwrap()` on an `Err` value: Http(Response { status: 403, version: HTTP/1.1, headers: {"content-length": "9"}, body: Some([70, 111, 114, 98, 105, 100, 100, 101, 110]) })',

from rains.

Comments (6)

rookie0 avatar rookie0 commented on August 23, 2024

给下具体 rust 版本及不指定报的错误,我用 1.69.0-nightly 本地编译测试没问题

指定报错 403 跟这些加的 header 没关系

from rains.

lucasjinreal avatar lucasjinreal commented on August 23, 2024

@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();

是我缺少了什么配置么

from rains.

rookie0 avatar rookie0 commented on August 23, 2024

403 是因为用的 header 不对,应该是 origin

InvalidHeader("sec-websocket-key") 的问题 macos 未复现,不确定是否是 tungstenite 这个库不支持 windows 平台,你可以从这方面跟下

image

from rains.

lucasjinreal avatar lucasjinreal commented on August 23, 2024

@rookie0 我mac下测试了也同样报错。
rust 是stable的最新版。

from rains.

lucasjinreal avatar lucasjinreal commented on August 23, 2024

btw, 我是mac M1 pro

from rains.

lucasjinreal avatar lucasjinreal commented on August 23, 2024

@rookie0 你clone一个git的不更改版本,编译一下看看么,我在公司电脑编译你的代码没有问题(windows),
在家用windows mac都会又那个runtime panic,缺少header。

是因为vpn?》??

这个问题让人丈二和尚摸不到头脑啊,

from rains.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.