1 year ago

#260924

test-img

Miacik cac

Start error (there is no reactor running, must be called from the context of a Tokio 1.x runtime) using s2n_quic with monoio runtime rust

I am trying to use monoio with s2n_quic to implement quic for this fast runtime. When run, it prints out

StartError:
there is no reactor running, must be called from the context of a Tokio 1.x runtime

Here is my code

use monoio;
use s2n_quic::{provider::connection_id, Server};
use std::error::Error;


fn main() -> Result<(), Box<dyn Error>> {
    
    let mut rt = monoio::RuntimeBuilder::new()
        .with_entries(1024)
        .enable_timer()
        .build()
        .unwrap();
    rt.block_on(async {
        println!("it works2!");
        let server = Server::builder();

        match server
            .with_connection_id(connection_id::Default::default()).unwrap()
            .with_io("127.0.0.1:8080").unwrap()
            .start()
        {
            Ok(mut serv) => {
                while let Some(mut connection) = serv.accept().await {
                    monoio::spawn(async move {
                        while let Ok(Some(mut stream)) =
                            connection.accept_bidirectional_stream().await
                        {
                            monoio::spawn(async move {
                                while let Ok(Some(data)) = stream.receive().await {
                                    stream.send(data).await.expect("stream should be open");
                                }
                            });
                        }
                    });
                }
            }
            Err(e) => {
                println!("{}", e);
            }
        }
    });

    Ok(())
}

To run it you will need 5.6 linux kernel.

rust

runtime

rust-tokio

quic

0 Answers

Your Answer

Accepted video resources