Hi guys,
I am trying to make my Rocket server to auto connect to - current IP address (only on Windows).
Everything seems to be fine but when I making cargo run I have OS error 99 like below.
Code:
fn main()
#[cfg(test)] mod tests;
#[get("/")]
fn hello() {
"Hello, world!"
}
//use rocket::config::{Config, Environment};
let cfg = rocket::config::Config::build(rocket::config::Environment::Development)
.address(my_internet_ip::get().unwrap().to_string())
.port(80)
.unwrap();
rocket::custom(cfg)
.mount("/", routes![hello])
.launch();
Terminal
Compiling diesel v0.1.0 (/home/user/diesel-simple)
Finished dev [unoptimized + debuginfo] target(s) in 4.84s
Running target/debug/diesel
:wrench: Configured for development.
=> address: 185.251.18.122
=> port: 80
=> log: normal
=> workers: 4
=> secret key: generated
=> limits: forms = 32KiB
=> keep-alive: 5s
=> tls: disabled
:artificial_satellite: Mounting /:
=> GET / (hello)
Error: Rocket failed to bind network socket to given address/port.
thread 'main' panicked at 'Cannot assign requested address (os error 99)', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.4.3/src/error.rs:192:17
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
I was wondering if maybe this is because my ip4 could not be public... but if i want to build web app, based on Rust,/Rocket how I can take requests from not a local network on any PC?
I am runing Rust on Ubuntu. Thank you for any help.
Most deployment scenarios are covered by 127.0.0.1 (localhost only, e.g. for a reverse proxy), or 0.0.0.0 (bind to all interfaces).
However, the error is likely due to the port being in use by another program. You can confirm this by trying different IP address / port combinations or using tools like netstat, but I am not familiar with the specifics of these tools on Windows.
Most deployment scenarios are covered by
127.0.0.1(localhost only, e.g. for a reverse proxy), or0.0.0.0(bind to all interfaces).However, the error is likely due to the port being in use by another program. You can confirm this by trying different IP address / port combinations or using tools like
netstat, but I am not familiar with the specifics of these tools on Windows.
Edit
I just realized that ip was pointed to 0.0.0.0 that is why on local it worked. But still same error on public IP :( Do I need to open port on ubuntu?
Do I need to open port on ubuntu?
If you can access the server on a local address but not from a public IP address, then you probably need to configure your firewall and/or router to allow traffic in.
I see that you used my_internet_ip - is your intent to give the public internet access to a web server running on your personal computer? We don't yet have a deployment guide, but even then I don't think it will cover that because it's a rare and often misguided setup.
rare and often misguided setup
Thank you it is very helpful. Yes i am trying to make something like that. I know it is not safe but it is only for my private use. I want to make some remote web app on my PCs to take some requests from public. I can make it just connecting to remote database but I am wondering if there are some tools like rocket or some others that can cover my needs if using rocket is impossible
It sounds like it is your personal internet connection that is at issue here - so any kind of server would have the same problem, not just Rocket. The necessary port forwarding and firewall configuration option(s) are fairly well documented elsewhere and outside of Rocket's scope.
And a friendly warning: you should investigate whether providing such a server is acceptable use of your internet service. Some Internet Service Providers might consider this abuse of their services and is against their internet subscriber contract(s). Whether it is considered abuse could depend on how much and what kind of traffic you have and who has access, but it is ultimately up to your internet provider if they consider it a problem.
Some Internet Service Providers might consider this abuse of their services and is against their internet subscriber contract(s).
Oh thank you. I wasn't thinking abut this that way. Thank you for your time jebrosen. I like learning by solving problems like that. Hope this will take me to some place. Have a nice day!