Closed zemelLeong closed 10 months ago
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:
403 Forbidden
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?;
Have you dumped the content of the HTTP request in both cases? I'm pretty sure there are some differences.
Beware the following things:
I can obtain websocket data normally through the websocat command:
But I got
403 Forbidden
when I usetokio_tungstenite 0.21.0
: