how do you handle disconnections? #61
Replies: 2 comments
-
here's a slight refactor that may show this a little more clearly: loop {
if let Some(item) = stream.try_next().await.expect("try_next failed") {
match item.expect("data empty") {
Data::Quote(q) => {
let message = format!(
"quote,s={} bp={},ap={} {}",
q.symbol,
q.bid_price,
q.ask_price,
q.timestamp.timestamp_nanos()
);
tx.send(message).await.unwrap()
}
_ => todo!(),
}
} else {
println!("this is where things go wrong");
println!("I think I need to reconnect to alpaca here");
println!("continuing this loop does nothing");
panic!("exiting");
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
I think you'd have to establish the connection all over again. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
websocket disconnections happen from time to time and I get an empty stream.
I'm currently iterating through a stream like this:
the
expect("stream empty")
part results in aProtocol(ResetWithoutClosingHandshake)
Generally speaking, how should someone handle these protocol resets?
Beta Was this translation helpful? Give feedback.
All reactions