Repository navigation
Releases
Releases · gbaranski/ezsockets
v0.7.1
v0.7.0
v0.6.4
What's Changed
- Guarantee the internal
SessionActoris dropped beforeServerExt::on_disconnectis called. - Return
CloseCode::Abnormalfrom keepalive timeouts instead ofCloseCode::Normal. - Fix DDOS by honest clients when servers check capacity after clients connect.
PRs
- Fix potential DDOS by honest clients when servers are at capacity by @UkoeHB in #108
- Use CloseCode::Abnormal in keepalive timeouts by @UkoeHB in #109
- Force-close clients on IO error by @UkoeHB in #110
- Guarantee SessionActor is dropped before close is handled by @UkoeHB in #107
- Improve clarity of disconnect handling by removing implicit behavior by @UkoeHB in #111
Full Changelog: v0.6.3...v0.6.4
v0.6.3
v0.6.2
v0.6.1
v0.6.0
- change
Client::close()to use reference instead ofself; removeasyncqualifier - feat: loosen
std::fmt::Debugconstrain onCallby @qiujiangkun in #39 - refactor: replace
SessionExt::Argswithhttp::Requestby @qiujiangkun and @gbaranski in #42 - add
ClientExt::on_disconnect()for socket closure and return aClientCloseCodefromClientExt::on_close()/on_disconnect()to control reconnect/full-close behavior by @UkoeHB - add
Session::close()method by @UkoeHB - fix server bug that would cause the server to crash if
ServerExt::on_connect()returned an error by @UkoeHB - return
Err(Option<CloseFrame>)fromServerExt::on_connect()to reject connections by @UkoeHB - robustness:
Server,Client,Session,Sinkinterfaces now returnResult<(), tokio::sync::mpsc::error::SendError>instead of potentially panicking by @UkoeHB - add reason to
ServerExt::on_disconnect()by @UkoeHB - improved tracing emitted during close sequences by @UkoeHB
- add
ClientConfig::query_parameter()so connection requests can pass data via the URI (since additional connection headers are not supported by the websockets spec, this method should be more compatible with other implementations) by @UkoeHB - removed panics from the internals by @UkoeHB
- downgraded tracing errors to warnings by @UkoeHB
- Return
Ok(MessageSignal)fromClientandSession.binary()/.text()/.close()endpoints instead ofOk(()). TheMessageSignal::state()method will indicate the current state of the message (sending/sent/failed). by @UkoeHB - Clients attempt to reconnect immediately instead of after one full reconnect interval. by @UkoeHB
- Incoming user messages are discarded while a client is reconnecting, to better match the usual behavior of a websocket connection. If you want messages to be buffered while reconnecting, you should implement your own buffer. by @UkoeHB
- Rename
socket::Config->socket::SocketConfigand add aheartbeat_ping_msg_fnmember variable in order to support custom Ping/Pong protocols. by @UkoeHB- Add
ClientConfig::socket_config()setter so clients can define their socket's config. - Add
ezsockets::axum::Upgrade::on_upgrade_with_config()that accepts aSocketConfig.
- Add
- Refactor
ezeockets::client::connect()to use a retry loop for the initial connection. Addmax_initial_connect_attemptsandmax_reconnect_attemptsoptions to theClientConfig(they default to 'infinite'). by @UkoeHB - Move
axumandtungsteniteserver runners into new submodulesrc/server_runners. by @UkoeHB - Update to
tokio-tungstenitev0.20.0. by @UkoeHB - Fork axum-tungstenite crate into
src/server_runnersand refactor theaxumrunner to use that instead ofaxum::extract::ws. by @UkoeHB - Bug fix: remove race condition between sending a message and a socket connection closing that would cause a client to shut down instead of calling
on_disconnect/on_close. by @UkoeHB - Use
tokio-tungstenite-wasmerrors internally to better support cross-platform clients. by @UkoeHB - Use
enfyncruntime handles internally to better support cross-platform clients. Default clients continue to use tokio. by @UkoeHB - Add
ClientConnectorabstraction for connecting clients and addezsockets::client::connect_with. by @UkoeHB - Add
ClientConnectorWasmandwasm_clientfeature. Addedchat-client-wasmexample to show a WASM client that compiles. It currently only listens to the chat and can't input anything since browser does not have a terminal. by @UkoeHB - Refactor
SocketandClientto not depend ontokiowhen compiling to WASM. This is a breaking change as theClientAPI now exposesasync_channelerror types instead oftokioerror types, andClient::call_with()now takes anasync_channel::Senderinstead of atokiooneshot. by @UkoeHB - Add unimplemented socket close codes. by @UkoeHB
- Add
ClientExt::on_connect_fail()for custom handling of connection attempt failures. By default the client will continue trying to connect. by @UkoeHB
Migration guide:
impl ezsockets::SessionExt for MySession {
type Args = (); // <----- 1. Remove Args on `SessionExt`
// ...
}
impl ezsockets::ServerExt for ChatServer {
// before
async fn on_connect(
&mut self,
socket: Socket,
address: SocketAddr,
args: <Self::Session as ezsockets::SessionExt>::Args, // <----- 2. Remove `args` argument
) -> Result<Session, Error> { todo!() }
// after
async fn on_connect(
&mut self,
socket: Socket,
request: ezsockets::Request, // <----- 3. Add `request: ezsockets::Request` argument.
// Note: `ezsockets::Request` is an alias for `http::Request`
address: SocketAddr,
) -> Result<Session, Option<CloseFrame>> { todo!() } // <----- 4. Return `CloseFrame` if rejecting connection.
// ...
}
// ONLY for `axum`
async fn websocket_handler(
Extension(server): Extension<Server<ChatServer>>,
ezsocket: Upgrade,
) -> impl IntoResponse {
let session_args = get_session_args();
// before:
ezsocket.on_upgrade(server, session_args) // <----- 5. Remove `session_args` argument
// after:
ezsocket.on_upgrade(server) // <----- Now you can customize the `Session` inside of `ServerExt::on_connect` via `ezsockets::Request`.
}
// ONLY for `tungstenite`
// before
ezsockets::tungstenite::run(
server,
"127.0.0.1:8080",
|_| async move { Ok(()) } // <----- 6. Remove the last argument,
// Now you can customize the `Session` inside of `ServerExt::on_connect` via `ezsockets::Request`
).await.unwrap();
// after
ezsockets::tungstenite::run(server, "127.0.0.1:8080") // Now you can customize the `Session` inside of `ServerExt::on_connect` via `ezsockets::Request`
.await
.unwrap();v0.5.1
v0.5.0
Breaking release!
- feat: add TLS support for servers(#31)
- refactor: rename methods and types for better distinction(#28)
| Before | After |
|---|---|
ClientExt::Params |
ClientExt::Call |
ClientExt::text(...) |
ClientExt::on_text(...) |
ClientExt::binary(...) |
ClientExt::on_binary(...) |
ClientExt::call(...) |
ClientExt::on_call(...) |
ClientExt::connected(...) |
ClientExt::on_connect(...) |
ClientExt::closed(...) |
ClientExt::closed(...) |
| - | - |
ServerExt::Params |
ServerExt::Call |
ServerExt::accept(...) |
ServerExt::on_connect(...) |
ServerExt::disconnected(...) |
ServerExt::on_disconnect(...) |
ServerExt::call(...) |
ServerExt::on_call(...) |
| - | - |
SessionExt::Params |
SessionExt::Call |
SessionExt::text(...) |
SessionExt::on_text(...) |
SessionExt::binary(...) |
SessionExt::on_binary(...) |
SessionExt::call(...) |
SessionExt::on_call(...) |
Additionally for the ezsockets::tungstenite::run_on function you need to also pass an ezsockets::tungstenite::Acceptor, if you don't use TLS, just pass ezsockets::tungstenite::Acceptor::Plain.
v0.4.3
What's Changed
- feat: connect request customisability by @gbaranski in #25
Full Changelog: v0.4.2...v0.4.3