Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

403 Forbidden #318

Closed
zemelLeong opened this issue Jan 7, 2024 · 1 comment
Closed

403 Forbidden #318

zemelLeong opened this issue Jan 7, 2024 · 1 comment
Labels

Comments

@zemelLeong
Copy link

zemelLeong commented Jan 7, 2024

I can obtain websocket data normally through the websocat command:

websocat ws://report-worker-2.noscription.org -H "Origin: https://noscription.org" -H "User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'"
{"eventId":"000002ae5f7f50394eea19e66e263f7e6fa4ccc9120349006178e2f3db5e1311"}
{"eventId":"000002ae5f7f50394eea19e66e263f7e6fa4ccc9120349006178e2f3db5e1311"}
{"eventId":"000002ae5f7f50394eea19e66e263f7e6fa4ccc9120349006178e2f3db5e1311"}

But I got 403 Forbidden when I use tokio_tungstenite 0.21.0:

fn get_ws_request() -> Request<()> {
    let mut request = "ws://report-worker-2.noscription.org".into_client_request().unwrap();
    request.headers_mut()
        .insert("Origin", "https://noscription.org".parse().unwrap());
    request.headers_mut()
        .insert("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36".parse().unwrap());


    request
}

    let request = get_ws_request();
    let (mut ws_stream, _) = tokio_tungstenite::connect_async(request).await?;
@daniel-abramov
Copy link
Member

Have you dumped the content of the HTTP request in both cases? I'm pretty sure there are some differences.

Beware the following things:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants