ResetWithoutClosingHandshake when server sends more frequent messages

Hello, I'm trying out this lib and found that it may not be able to handle heavy loads?
Under normal circumstances everything works fine. But as soon as I subscribe to more server events, it drops.

Should I reconnect in this case? If yes how?

    let (ws_stream, _) = connect_async(&base).await.unwrap();
    
    let (write, read) = ws_stream.split();

    let ws_to_stdout = read.for_each(|message| async move {

        dbg!(&message);

        let msg = match message {
            Ok(m) => m,
            Err(_) => {
 // 2021-09-02 20:57:00 - ERROR: Error reading message: Protocol(ResetWithoutClosingHandshake)

                todo!()
            }
        };      

After roughly 1 minute, the connection gets dropped. No ping frame received.

2021-09-02 20:57:00 - ERROR: Error reading message: Protocol(ResetWithoutClosingHandshake)

Update: I found that this only happens when using dbg!() or printing anything to the console. Is there any way to prevent this?

Hard to say with so few information. Can you post a full example that compiles without errors? The snippet you wrote is truncated, the for_each is not even closed. And maybe provide more details on what you are doing. (You didn’t even say what is the lib you are using, though I recognize tokio-tungstenite.)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.