From 9aa972dd83a85cec5da71e8e893eb6e07d5db8ca Mon Sep 17 00:00:00 2001 From: hozan23 Date: Fri, 21 Jun 2024 22:45:17 +0200 Subject: jsonrpc/client: fix subscription error when the subscriber cannot keep up Add a limit for receiving notifications for the subscription. If this limit is exceeded, the client will stop and raise an error. The limit is configurable when building a new client. --- jsonrpc/examples/pubsub_client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'jsonrpc/examples/pubsub_client.rs') diff --git a/jsonrpc/examples/pubsub_client.rs b/jsonrpc/examples/pubsub_client.rs index 73570b8..bbfd9b4 100644 --- a/jsonrpc/examples/pubsub_client.rs +++ b/jsonrpc/examples/pubsub_client.rs @@ -19,7 +19,7 @@ async fn run_client() { let clientc = client.clone(); smol::spawn(async move {}).detach(); - let (_, sub) = client + let sub = client .subscribe("Calc.log_subscribe", ()) .await .expect("Subscribe to log_subscribe method"); @@ -33,7 +33,7 @@ async fn run_client() { .detach(); loop { - Timer::after(Duration::from_secs(1)).await; + Timer::after(Duration::from_millis(500)).await; let _: Pong = clientc .call("Calc.ping", ()) .await -- cgit v1.2.3