Unverified Commit a0813cbd authored by Alexandru Vasile's avatar Alexandru Vasile Committed by GitHub
Browse files

Implement `ping-pong` for WebSocket clients (#772)



* ws: Implement ping for `TransportSenderT` trait
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* ws/client: Receive pong frames
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* core/client: Use `select!` macro for the background task
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Propagate ping interval to background task
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* async_client: Submit ping requests
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* async_client: Handle pong replies
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Handle frontend messages to dedicated fn
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Handle backend messages in dedicated fn
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Add terminated fuse for opt-out pings
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Set opt-out behavior for client pings
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Move imports
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Handle handle_frontend_messages errors
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Add custom error related to byteslice conversions
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Modify `send_ping` to send empty slices
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Fix `cargo hack check` and use `select_biased`
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Handle sending pings with lowest priority
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* core: Add proper number of params to `background_task`
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Fix wasm client
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Handle raw bytes and string received messages
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Fix Cargo.toml feature
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Panic when empty slice does not fit into `ByteSlice125`
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* wasm: Add operation not supported for pings
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Rename `ReceivedMessage` from Data to Text
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Rename test variable
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Add documentation
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Use `future::select` for  cancel safety
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Remove `pong` handling logic
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* client: Update ping documentation
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Update core/src/client/async_client/mod.rs
Co-authored-by: default avatarTarik Gul <47201679+TarikGul@users.noreply.github.com>

* Update core/src/client/async_client/mod.rs
Co-authored-by: default avatarTarik Gul <47201679+TarikGul@users.noreply.github.com>

* Update core/src/client/async_client/mod.rs
Co-authored-by: default avatarTarik Gul <47201679+TarikGul@users.noreply.github.com>

* Update core/src/client/async_client/mod.rs
Co-authored-by: default avatarTarik Gul <47201679+TarikGul@users.noreply.github.com>

* Update core/src/client/async_client/mod.rs
Co-authored-by: default avatarTarik Gul <47201679+TarikGul@users.noreply.github.com>

* Update core/Cargo.toml
Co-authored-by: Niklas Adolfsson's avatarNiklas Adolfsson <niklasadolfsson1@gmail.com>

* Update core/Cargo.toml
Co-authored-by: Niklas Adolfsson's avatarNiklas Adolfsson <niklasadolfsson1@gmail.com>

* logs: Keep debug log for submitting `Ping` frames
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Print debug logs when receiving `Pong` frames
Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>

* Update core/src/client/async_client/mod.rs
Co-authored-by: default avatarTarik Gul <47201679+TarikGul@users.noreply.github.com>
Co-authored-by: Niklas Adolfsson's avatarNiklas Adolfsson <niklasadolfsson1@gmail.com>
parent 2ac4cb26
Pipeline #196851 passed with stages
in 5 minutes and 27 seconds