pub(super) fn connect_with_retry(url: &str, timeout: Option<u64>) -> WebSocket<AutoStream> {
    let count = 3;
    let mut error_msg: String = String::new();
    for i in 0..count {
        let res = connect_with_timeout(url, timeout);
        match res {
            Ok((ws_stream, _)) => return ws_stream,
            Err(err) => {
                warn!("Error connecting to {}, {}, aborted", url, err);
                thread::sleep(time::Duration::from_secs(3));
                if i == count - 1 {
                    error_msg = err.to_string();
                }
            }
        }
    }

    panic!("Error connecting to {}, {}, aborted", url, error_msg);
}
// This function is equivalent to tungstenite::connect(), with an additional benefit that
// it can make read_message() timeout after 5 seconds
This function is equivalent to tungstenite::connect(), with an additional benefit that
it can make read_message() timeout after 5 seconds
This function is equivalent to tungstenite :: connect () with an additional benefit that it can make read_message () timeout after 5 seconds
pub(super) fn connect_with_retry(url: &str, timeout: Option<u64>) -> WebSocket<AutoStream> {
    let count = 3;
    let mut error_msg: String = String::new();
    for i in 0..count {
        let res = connect_with_timeout(url, timeout);
        match res {
            Ok((ws_stream, _)) => return ws_stream,
            Err(err) => {
                warn!("Error connecting to {}, {}, aborted", url, err);
                thread::sleep(time::Duration::from_secs(3));
                if i == count - 1 {
                    error_msg = err.to_string();
                }
            }
        }
    }
    panic!("Error connecting to {}, {}, aborted", url, error_msg);
}
pub ( super ) fn connect_with_retry ( url : & str , timeout : Option < u64 > ) -> WebSocket < AutoStream > { let count = 3 ; let mut error_msg : String = String :: new ( ) ; for i in 0 .. count { let res = connect_with_timeout ( url , timeout ) ; match res { Ok ( ( ws_stream , _ ) ) => return ws_stream , Err ( err ) => { warn ! ( " " url err ) ; thread :: sleep ( time :: Duration :: from_secs ( 3 ) ) ; if i == count - 1 { error_msg = err . to_string ( ) ; } } } } panic ! ( " " url error_msg ) ; }
This function is equivalent to tungstenite::connect(), with an additional benefit that
it can make read_message() timeout after 5 seconds
This function is equivalent to tungstenite :: connect () with an additional benefit that it can make read_message () timeout after 5 seconds
url
&str
timeout
Option<u64>