avitex / rust-public-ip

Find the public IP address of a device
MIT License
28 stars 7 forks source link

Panic due to missing Tokio reactor #19

Closed mwbryant closed 2 years ago

mwbryant commented 2 years ago

I'm trying to use this library in a project using the bevy game engine. Upon running I see this error:

thread 'main' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime', /home/matthew/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-system-resolver-0.5.0/src/system.rs:43:9

The line I'm trying to run is:

 let public_ip = block_on(public_ip::addr()).unwrap();

This happens on all combinations of features I have tried.

mwbryant commented 2 years ago

Solved by creating my own Tokio runtime:

    let mut rt = Runtime::new().unwrap();
    let public_ip = rt.block_on(public_ip::addr()).unwrap();