actix / actix-web

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
https://actix.rs
Apache License 2.0
21.19k stars 1.65k forks source link

[Bug]Awc client connect websocket ignore the port #3430

Closed zerodegress closed 3 weeks ago

zerodegress commented 1 month ago

Expected Behavior

code like below should perform connection to websocket server correctly

let (_, conn) = awc::Client::builder().finish().ws("ws://127.0.0.1:9090/").address(addr).connect().await.map_err(|e| {
        println!("{:?}", e);
    }).unwrap()

Current Behavior

图片

the server responses 400, here's the wireshark captured 图片

Possible Solution

noticed that the upgrade request: 图片

and the code here in awc ws.rs: 图片

according to mdn, i thought maybe the port should be appended to the host, like this: host: 127.0.0.1:9090

Steps to Reproduce (for bugs)

1.install required dependencies(actix_rt, awc) 2.simply run the code above

Context

trying to connect the rosbridge_server(ros kinetic) in websocket protocol.

Your Environment

zerodegress commented 1 month ago

tempory solution(maybe):

let (_, conn) = awc::Client::builder().finish().ws("ws://127.0.0.1:9090/").set_header(actix_http::header::HOST, "127.0.0.1:9090").connect().await.map_err(|e| {
        println!("{:?}", e);
    }).unwrap();
robjtede commented 3 weeks ago

Seems like http uses a non-standard definition of "host" since the .host() method actually returns the "hostname".

robjtede commented 3 weeks ago

fixed in 5ad92c0062c3ee972005b9c2b0bbb0c2d5d59fbb

robjtede commented 3 weeks ago

released in https://github.com/actix/actix-web/releases/tag/awc-v3.5.1