Skip to content

Commit 3c57bc0

Browse files
connect error handling
1 parent 09037ba commit 3c57bc0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cluster-endpoints/examples/grpc_using_streams.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,22 @@ async fn create_geyser_stream2(label: String, grpc_addr: String, x_token: Option
192192
stream! {
193193
let mut throttle_barrier;
194194
'main_loop: loop {
195-
throttle_barrier = Instant::now().add(Duration::from_millis(500));
195+
throttle_barrier = Instant::now().add(Duration::from_millis(1000));
196196

197197
// throws e.g. InvalidUri(InvalidUri(InvalidAuthority))
198198
// GeyserGrpcClientError
199-
let client_result = GeyserGrpcClient::connect(grpc_addr.clone(), x_token.clone(), None);
199+
let connect_result = GeyserGrpcClient::connect_with_timeout(
200+
grpc_addr.clone(), x_token.clone(), None,
201+
Some(Duration::from_secs(2)), Some(Duration::from_secs(2)), false).await;
200202

201-
if let Err(client_connect_error) = client_result {
203+
if let Err(client_connect_error) = connect_result {
202204
// TODO identify non-recoverable errors and cancel stream
203-
warn!("Connect failed and will be retried: {:?}", client_connect_error);
205+
warn!("Connect failed - retrying: {:?}", client_connect_error);
204206
sleep_until(throttle_barrier).await;
205207
continue 'main_loop;
206208
}
207209

208-
let mut client = client_result.unwrap();
210+
let mut client = connect_result.unwrap();
209211

210212
let mut blocks_subs = HashMap::new();
211213
blocks_subs.insert(

0 commit comments

Comments
 (0)