Closed
Description
Problem
I tried to use the new websocket feature from server_fn
0.8. I tried to roughly replicate the example from the release notes and I came up with this:
https://github.com/niclashoyer/dioxus-ws/blob/main/src/main.rs
Using dx serve
it seems that the ws connection is proxied through, but I get the following error and the ws connection is closed:
18:52:01 [dev] Proxying websocket connection Request { method: GET, uri: /api/echo12519339549662162813, version: HTTP/1.1, headers: {"host": "localhost:8080", "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0", "accept": "*/*", "accept-language": "de,en-US;q=0.7,en;q=0.3", "accept-encoding": "gzip, deflate, br, zstd", "sec-websocket-version": "13", "origin": "http://localhost:8080", "sec-websocket-extensions": "permessage-deflate", "sec-websocket-key": "SL8x2x2RNq1sRtAdHwku5A==", "connection": "keep-alive, Upgrade", "sec-fetch-dest": "empty", "sec-fetch-mode": "websocket", "sec-fetch-site": "same-origin", "pragma": "no-cache", "cache-control": "no-cache", "upgrade": "websocket", "x-proxied-by-dioxus": "true"}, body: Body(UnsyncBoxBody) }
18:52:01 [dev] Connection proxied to ws://127.0.0.1:44717/api/echo12519339549662162813
18:52:01 [dev] Error proxying websocket connection: Error connecting to server: HTTP error: 200 OK
18:52:01 [server] ERROR error generating HTTP response: WebSocket protocol error: Connection reset without closing handshake
18:52:01 [web] WebSocket Closed: code: 1006, reason:
Steps To Reproduce
git clone https://github.com/niclashoyer/dioxus-ws.git
cd dixous-ws
cargo install --git https://github.com/DioxusLabs/dioxus.git --rev cb651a8 --root . dioxus-cli
bin/dx serve
Expected behavior
Websocket connection is correctly handled by server function / axum.
Environment:
- Dioxus version: main, cb651a8
- Rust version: 1.86.0
- OS info: Fedora Linux 41
- App platform: web fullstack
Questionnaire