Skip to content

Commit 251acc8

Browse files
author
DogLooksGood
committed
Add retry on PubsubClient creation
1 parent ece48b3 commit 251acc8

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

transport/src/solana.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,13 +1199,19 @@ impl TransportT for SolanaTransport {
11991199
let game_account_pubkey = Self::parse_pubkey(addr)?;
12001200
let addr = addr.to_owned();
12011201

1202-
let client = match PubsubClient::new(&ws_rpc).await {
1203-
Ok(client) => client,
1204-
Err(e) => {
1205-
error!("Failed to create PubsubClient due to {:?}", e);
1206-
return Err(Error::TransportError(e.to_string()));
1207-
}
1208-
};
1202+
let client;
1203+
loop {
1204+
match PubsubClient::new(&ws_rpc).await {
1205+
Ok(c) => {
1206+
client = c;
1207+
break;
1208+
}
1209+
Err(e) => {
1210+
error!("Failed to create PubsubClient due to {:?}, will retry.", e);
1211+
tokio::time::sleep(Duration::from_secs(10)).await;
1212+
}
1213+
};
1214+
}
12091215

12101216
Ok(Box::pin(stream! {
12111217
let (mut stream, unsub) = match client

0 commit comments

Comments
 (0)