New release!
Today we’re releasing new IC WebSocket versions that affect both the SDKs and the gateway.
New versions
SDKs:
Gateway:
What’s changed
SDKs
We suggest you to update all your SDKs to the latest version.
- you can close the connection with the client from the canister using the newly introduced
close
CDK method:- Rust:
ic_websocket_cdk::close(client_principal);
- Motoko:
await ws.close(client_principal); // or (but doesn't call the on_close callback): // await IcWebSocketCdk.close(ws_state, client_principal);
- Rust:
- you don’t have to specify the keep alive timeout parameter anymore (if you were doing it)
- Rust: the WsInitParams struct doesn’t have the
keep_alive_timeout_ms
field anymore. - Motoko: WsInitParams are now initialized with one argument less:
- let params = IcWebSocketCdkTypes.WsInitParams(null, null, null); + let params = IcWebSocketCdkTypes.WsInitParams(null, null);
- Rust: the WsInitParams struct doesn’t have the
ws_send
is deprecated, usesend
instead:- Rust:
- ic_websocket_cdk::ws_send(client_principal, message_bytes); + ic_websocket_cdk::send(client_principal, message_bytes);
- Motoko:
- await IcWebSocketCdk.ws_send(ws_state, client_principal, msg_bytes) + await IcWebSocketCdk.send(ws_state, client_principal, msg_bytes)
- Rust:
You can also follow the updated tutorial for reference.
Gateway
- fix: call
ws_close
when canister closes connection (even with an error)