seanmonstar / warp

A super-easy, composable, web server framework for warp speeds.
https://seanmonstar.com/post/176530511587/warp
MIT License
9.59k stars 723 forks source link

websocket disconnect (code: 1006, reason: "") #1074

Closed thewh1teagle closed 1 year ago

thewh1teagle commented 1 year ago

Version warp = { version = "0.3.6", features = ["tls"] }

cargo install cargo-tree (see install here: https://github.com/sfackler/cargo-tree)

Then:


cargo tree | findstr warp
warp v0.3.6

Platform Windowx x64

Description I made websocket server using warp and I connect it with websocat after few minutes the client disconnect from the server unexpectedly

I connect it using

websocat.exe ws://127.0.0.1:3030/ws

and after few minutes it exit with:

Connected (press CTRL+C to quit)
Disconnected (code: 1006, reason: "")

You can see the short server implementation here: https://github.com/thewh1teagle/oref-rs/blob/main/oref-ws/src/main.rs#L103

thewh1teagle commented 1 year ago

I think it's because there's no data which sent on the wire and warp doesn't use ping to keep the connection.

How can I send ping to the clients?

thewh1teagle commented 1 year ago

Update: I added function which run in background and ping every client every 55 seconds, it solved the problem. You can see example here