-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Launching multiple rockets on the same port does not report an error. #209
Comments
Using rocket::custom does trigger the expected error, but not rocket::ignite in the hello world example. |
The path for listening for requests for But I've noticed the general issue as well. Unfortunately, Rocket just asks Hyper to start listening, so it would seem that the issue, if any, is on Hyper's side. |
I've found some interesting details. In my draft like PR for Port auto config (#210) I have changed the logging to print the resulting address from the HttpListener, and this is the results when launching three hello_world-rockets in series: First launch: Second launch: Third launch attempt: It seems like some part of hyper or perhaps std::net is choosing to use ipv4 if the ipv6 port was in use, that seems like a bug or at least a very surprising behavior. :) I have not tried to do the same test with std::net::TcpListener yet (which hyper depends on). |
Thanks for looking into this! This makes it pretty clear what's going on, actually.
Are you certain that |
I just tested the same thing with TcpListener and is behaves in the same way, which seems kind of expected when thinking about it. Like you say the hostname does not specify ipv4 or ipv6. |
What I would expect |
I had not thought about that. Mine does indeed specify both ::1 and 127.0.0.1. |
@anderejd So it looks like the Rust folks are aware of this ambiguity. See https://github.com/alexcrichton/rfcs/blob/net2.1/text/0000-io-net-2.1.md#tosocketaddrs-and-multiple-addresses, for instance. I'm not sure what Rocket should be doing here. We can certainly open sockets to all addresses resolved by a hostname and then create a new |
I think what happens now is suboptimal, but I also don't think that this is something Rocket should deal with directly. The standard library, underlying HTTP library, or both, should have clearer semantics. Let's make sure we make this clear by the time #17 is ready to address. Closing this for now. |
Has any more thought gone into the issues raised here and at #491? In order to support both IPv4 and IPv6, the standard way is to create an IPv6 socket and turn off the |
Hi, based on my (very current) experience, I'd like to suggest adding a note about this issue in some fairly visible place in the docs. I just wasted about an hour to debug why my server doesn't accept a request, searching for bugs in my code, only to realize that all the requests were actually going to a different instance of the server that was still running in a It would never cross my mind that such bug is even possible and I believe that Rocket is the first thing many people will blame if they stumble upon this error themselves. |
My very first experience of Rust and Rocket was running into this issue... via using siege to benchmark too (there's another ticket for this). This is a seriously weird and problematic behaviour, that I've never run into in the history of developing for the web. Certainly doesn't give me a good impression of this platform for my own projects. Minimally Rocket should have some docs about this. I doubt Im so special Im the only one to run into this straight away. Even if its underlying server deps causing the problem, the instance of user error is via Rocket, you probably want to poke whoever is responsible some more. |
Coming back to this issue, I think it would make sense to change the default address for |
To begin with, thank you for this project! The documentation and introduction is fantastic.
I tried to start two processes of the hello world example and expected the second one to fail with some error like "Address already in use" but instead the second process reports success on the same hostname and port as the first process.
I looked through the code for rocket 0.2.0 and hyper 0.10.4 but did not find the problem. When instead trying std::net::TcpListener I do get the expected error.
The text was updated successfully, but these errors were encountered: