BiagioFesta / wtransport

Async-friendly WebTransport implementation in Rust
Apache License 2.0
470 stars 31 forks source link

Way to open bidirectional connection from the server. #230

Closed Banou26 closed 1 month ago

Banou26 commented 1 month ago

Hello

It seems like there's currently no way to open a bidirectional connection from the server side. incoming_session.await?.quic_connection.open_bi().await? would be the way to do it if it were to return a (SendStream, RecvStream). But quic_connection is private and open_bi returns a OpenBi<'_>.

I've not found a way while reading through documentation and looking at some of the code, so I'm guessing it's not implemented yet. Is it planned to be?

BiagioFesta commented 1 month ago

wtransport::Connection has open_bi method. Each WebTransport connection (regardless if on client or server) can open a bidirectional stream.

For example:

    let endpoint = Endpoint::server(
        ServerConfig::builder()
            .with_bind_default(4433)
            .with_identity(Identity::self_signed(["localhost"]).unwrap())
            .build(),
    )
    .unwrap();

    let connection = endpoint
        .accept()
        .await
        .await
        .unwrap()
        .accept()
        .await
        .unwrap();

    connection.open_bi().await.unwrap();

Note: please be aware quic_connection (behind feature quinn) is only there to access underlying QUIC connection (generally you should not need it).

Banou26 commented 1 month ago

Oohhh, my bad, i literally just noticed that i was running an old version of wtransport, updated it and noticed it was properly exposed now! Sorry about this, and thanks for this amazing library!