Why do I get the error “there is no reactor running, must be called from the context of Tokio runtime” even though I have #[tokio::main]?

前端 未结 1 365
萌比男神i
萌比男神i 2021-01-12 11:48

I\'m following the mdns Rust documentation and pasted the example code but it throws the following error:

thread \'ma         


        
相关标签:
1条回答
  • 2021-01-12 12:36

    You are using a newer version of Tokio, such as 0.3 or 1.0 and many packages, including mdns 1.1.0, rely on an older version of Tokio, such as 0.2.

    % cargo tree -d
    tokio v0.2.22
    └── mdns v1.1.0
        └── example_project v0.1.0
    
    tokio v0.3.3
    └── example_project v0.1.0
    

    For now, you will need to match versions of the Tokio runtime. The easiest way is to use Tokio 0.2 yourself. The tokio-compat-02 crate may also be useful in some cases.

    See also:

    • Why is a trait not implemented for a type that clearly has it implemented?

    Various error messages with the same root cause:

    there is no reactor running, must be called from the context of Tokio runtime

    not currently running on the Tokio runtime

    0 讨论(0)
提交回复
热议问题