Skip to content

Releases: gbaranski/ezsockets

v0.6.4

07 Sep 10:36
Compare
Choose a tag to compare

What's Changed

  • Guarantee the internal SessionActor is dropped before ServerExt::on_disconnect is called.
  • Return CloseCode::Abnormal from keepalive timeouts instead of CloseCode::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

07 Sep 10:35
Compare
Choose a tag to compare

What's Changed

  • Allow users to use tokio v2.4.0 in their projects. See #106.

PRs

New Contributors

Full Changelog: v0.6.2...v0.6.3

v0.6.2

07 Sep 10:35
Compare
Choose a tag to compare

What's Changed

  • Add MessageSignal::new().

PRs

Full Changelog: v0.6.0...v0.6.2

v0.6.1

16 Nov 14:13
Compare
Choose a tag to compare
  • Tighten cleanup guarantees for outgoing client messages in reconnect cycles. @UkoeHB

v0.6.0

16 Nov 14:11
Compare
Choose a tag to compare
  • change Client::close() to use reference instead of self; remove async qualifier
  • feat: loosen std::fmt::Debug constrain on Call by @qiujiangkun in #39
  • refactor: replace SessionExt::Args with http::Request by @qiujiangkun and @gbaranski in #42
  • add ClientExt::on_disconnect() for socket closure and return a ClientCloseCode from ClientExt::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>) from ServerExt::on_connect() to reject connections by @UkoeHB
  • robustness: Server, Client, Session, Sink interfaces now return Result<(), 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) from Client and Session .binary()/.text()/.close() endpoints instead of Ok(()). The MessageSignal::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::SocketConfig and add a heartbeat_ping_msg_fn member 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 a SocketConfig.
  • Refactor ezeockets::client::connect() to use a retry loop for the initial connection. Add max_initial_connect_attempts and max_reconnect_attempts options to the ClientConfig (they default to 'infinite'). by @UkoeHB
  • Move axum and tungstenite server runners into new submodule src/server_runners. by @UkoeHB
  • Update to tokio-tungstenite v0.20.0. by @UkoeHB
  • Fork axum-tungstenite crate into src/server_runners and refactor the axum runner to use that instead of axum::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-wasm errors internally to better support cross-platform clients. by @UkoeHB
  • Use enfync runtime handles internally to better support cross-platform clients. Default clients continue to use tokio. by @UkoeHB
  • Add ClientConnector abstraction for connecting clients and add ezsockets::client::connect_with. by @UkoeHB
  • Add ClientConnectorWasm and wasm_client feature. Added chat-client-wasm example 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 Socket and Client to not depend on tokio when compiling to WASM. This is a breaking change as the Client API now exposes async_channel error types instead of tokio error types, and Client::call_with() now takes an async_channel::Sender instead of a tokio oneshot. 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

17 Mar 12:07
Compare
Choose a tag to compare
  • fix examples links in README.md

v0.5.0

17 Mar 03:36
Compare
Choose a tag to compare

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

05 Mar 23:27
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.4.2...v0.4.3

v0.4.2

04 Mar 13:14
Compare
Choose a tag to compare

What's Changed

v0.4.1

03 Mar 01:54
Compare
Choose a tag to compare
  • add close() function on Client
  • update dependencies
  • improve docs.rs documentation
  • fix mistakes in README
  • add benchmarks
  • use biased non-random tokio::select