Skip to content

Split rx continues after tx is closed #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
huntc opened this issue May 20, 2025 · 5 comments
Open

Split rx continues after tx is closed #63

huntc opened this issue May 20, 2025 · 5 comments

Comments

@huntc
Copy link

huntc commented May 20, 2025

My expectation when splitting the rx and tx was that closing the tx would cause the rx.read call to fail the read or generate a close message. Neither happens, and the receive function continuous. Is this the expected behaviour? If so then should we periodically timeout the read to test whether the connection remains open?

    println!("starting");
    loop {
        match rx.read(&mut buf).await? {
            Message::Text => {
                let _s = String::from_utf8(buf.to_vec())?;
                tx.write(&mut buf, PayloadType::Text).await?;
                tx.flush().await?;
                buf.clear();
                println!("closing tx");
                tx.close(ratchet_core::CloseReason {
                    code: ratchet_core::CloseCode::GoingAway,
                    description: None,
                })
                .await?;
            }
            Message::Binary => {
                tx.write(&mut buf, PayloadType::Binary).await?;
                tx.flush().await?;
                buf.clear();
            }
            Message::Ping(_) | Message::Pong(_) => {}
            Message::Close(_) => {
                println!("ending");
                return Ok(());
            }
        }
    }
@huntc
Copy link
Author

huntc commented May 23, 2025

Howdy. Just wondering if there are any thoughts on this? I can imagine this being problematic for any use of splitting the socket. Thanks.

@SirCipher
Copy link
Member

Hey @huntc, in theory the read half should terminate automatically once it receives the echoed close frame. I'll have to have a look into this to see if it's not happening as expected

@huntc
Copy link
Author

huntc commented May 23, 2025

Thanks @SirCipher ! Hopefully, the above code modifications to the autobahn-split-server.rs help you reproduce the problem, as they did for me.

@huntc
Copy link
Author

huntc commented May 27, 2025

Hi @SirCipher - is there anything I can do here? Happy to push a PR if you can guide me on what area I should be looking at. Thanks.

@huntc
Copy link
Author

huntc commented Jun 11, 2025

Were you able to reproduce it @SirCipher ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants