-
Notifications
You must be signed in to change notification settings - Fork 6
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
getaddrinfo: -9
when connecting to localhost
#43
Comments
-9 may be the gai_error "EAI_SOCKTYPE The SOCTYPE was not recognized." What this most probably means is that "localhost" on that system is I can check the epollcat |
At a higher level. I have been pecking my way towards IPv6 support, leaving trail of From my studies so far, there are some things in epollcat which need to change. The harder area is that The other alternative is to implement just the parts of ConfigurationTo refresh prior rapid discussions. Java defines two System Properties (I may get the names wrong here, but JVM will use IPv6 as the underlying socket if any network interface Thunder storms, system may crash. More later. |
Back from thunderstorms. TL;DR Based on discussions outside this context, I think that epollcat This gives a clear "opt-out". I think that is essential. This does get into the game of telling people to set System Properties Adopting this convention, at least for scaffolding or until I think that puts my examining the SN InetAddress & kin change, Your thoughts? |
Thank you for sharing all your thoughts and summarizing the key points. I have been mulling on this issue as well.
I followed the discussion on Scala Native, and I absolutely agree with you on this.
Yes, this makes sense to me. We do possibly have one other option at our disposal: a Cats Effect Indeed, I have been planning to introduce an
So in theory, we could also add a flag for enabling/disabling IPv6 to such a configuration object. See also how the default What are your thoughts about this? I could go either way: on the one hand, exposing the configuration like this is taking a step away from the JVM. On the other hand, it may be a better UX and is idiomatic for Cats Effect applications. I do have one concern: we do not control the implementation of
|
Throws the expected ConnectException:
Can you try that test or its equivalent on your system? Separately, if that test fails, could you send me privately the results from:
|
@LeeTibbert here is a test that demonstrates the issue (and shows off your brand new error messages! :) test("connect localhost".only) {
val localhost = new InetSocketAddress(InetAddress.getByName("localhost"), 8888)
val `127.0.0.1` = new InetSocketAddress("127.0.0.1", 8888)
IOServerSocketChannel
.open
.evalTap(_.bind(new InetSocketAddress("0.0.0.0", 8888)))
.surround {
for {
result1 <- IOSocketChannel.open.use(_.connect(localhost)).attempt
_ <- IO.println(result1)
result2 <- IOSocketChannel.open.use(_.connect(`127.0.0.1`)).attempt
_ <- IO.println(result2)
} yield ()
}
} Which gets me this result:
You can see the two If I run the same test on the JVM I get this:
|
A rich discussion, perhaps a chance to move the stone a few millimeters uphill.
Yes, if they do not that is a blunder on my part and a bug. The properties Opps, context switch back to the original "localhost" concern. One quick thought: your concern about "who does what when" Something for me to think about. More later (tomorrow-ish). |
Indeed this seems to be the case in the forthcoming SN 0.5.x. However, that is not the case in 0.4.x, and it seems that |
I ran the tests both as me and as root. Both cases I got the Connect Timeout. What does CI do with this test? "localhost" is almost always IPv6. Equivalent name for IPv6 is "ip6-localhost" Some people also define IPv6 AAAA records for localhost and then Adding the test, at least for debugging, to CI will |
I will look at the 0.4.7 implementation tomorrow. If it is returning an IPv6 address on "standard" systems, I'll hang tight for a few minutes to see what CI says. You have me more curious than hungry. |
CI seems All Green. I can Discourse PM you my email (or you may have it already), or you |
Yes, CI is green but the
https://github.com/armanbilge/epollcat/runs/8296491638?check_suite_focus=true#step:9:44 |
Rats! If I remove the ".attempt" from (a copy) of the test, will the Exception bubble through? At least now we see where the weight of the evidence lies. |
Yes, the |
When I add a single IO(printf) I now get what I would call expected behavior. First : I would say that the second timeout is expected because the server socket never does an Tomorrow I will start with a freshly re-based clone in an empty directory. I will also |
The one CI log file I looked at gives two Rights. So both succeeded.
I check the log file that you posted that had the obvious failure. |
Yes, from the CI logs I looked at, I understand it to be working on the JVM and failing on Native. |
OK, I was distracted by JVM. I will focus on the Native. Too many shells moving around on the table. |
Well, at least we got rid of the -9 the title mentions. A small victory for the day. re: SN 0.4.n InetAddress returning IPv6 addresses for getByName() Having studied the 0.4.n InetAddress code, I concur with your discovery. I can create an Issue in Scala Native. The obvious fix is to change Off the top of my head, epollcat can do one of two thing:
2a) Explore implementing an improved & simplified InetAddress. re: localhost From the error messages, we had surmised that on SN, Trying to guess what was going on in CI, I wrote a WIP (work in progress) Now this is astonishing! It is quite unusual, but not unheard of for However it came to be, we have two existence proofs that it does happen and that Arman, if you concur, I think the next step is for me to modify In the general case, say connecting to The same situation probably shows up in bind(). I will also What a thicket! Good you found this. Have I earned my supper? Good night. Interesting ride, good conversation. |
Ha, suppertime indeed! Thanks for your persistence on this one 😅 Regarding your proposals:
Forgive me if I'm confused about the real problem here, but it seems to me there's an elephant in the room: can we not solve this by:
So far the lack of IPv6 support has caused problems in fs2-io, http4s, and skunk. So I think it's time to bite the bullet and do what I should have done in the first place, had I not misunderstood the state of IPv6 in Scala Native 0.4.x. |
This is a complex discussion and will take some back and forth. These two items directly conflict.
epollcat is using a blend of SN implementation (InetAddress, etc) and its own, AsyncSocket, etc.
After the A good part of that is writing tests. Trying to do the A second part of epollcat IPv6 support would be
This is useful to know. I think it falls into the category of "bad news which is good news", To synchronize. My plan had been to l
|
If the flag is set, all IPv4 addresses (127.0.0.1) should be mapped to IPv4MappedIPv6 addresses (::FF:127.0.0.1 or its Forgive me if I get too concrete, geekish, or simple: The Java System Property "java.net.preferIPv6Addresses" gives a hint to getaddrinfo to return AAAA records first The SN 0.4.7 (and prior) code specifies AF_UNSPEC (unspecified) in the hints it gives to gai. This lets gai Currently, on you system & the CI system(s) but not on my system, the environment is configured for |
We are trying to cover material that covers several semesters of To ground the discussion, if for no one other than me:
|
To be honest, I don't understand this at all. epollcat is barely using I apologize if I was unclear, but I do not thing we should attempt to override the Scala Native implementation of
Another point I am confused about: where in its implementation is epollcat querying name servers? epollcat only works directly with IP addresses; never with hostnames. Therefore it should never be querying any name server, to the best of my knowledge. In epollcat the two methods called with an address are epollcat/core/src/main/scala/epollcat/internal/ch/EpollAsyncSocketChannel.scala Lines 178 to 186 in 67ca8bc
epollcat/core/src/main/scala/epollcat/internal/ch/EpollAsyncServerSocketChannel.scala Lines 73 to 76 in 67ca8bc
In both cases the address is assumed to be already resolved to an IP address. Thus to me it seems the only way forward is to be able to handle both IPv4 and IPv6 inputs with help from |
Understood and agreed.
|
Eventually (and a lot sooner if we punt InetAddress.getByName() concerns), that is true. AI_V4MAPPED is almost The recent (2 decade) practice in C land is to call getaddrinfo with AF_UNSPEC, TCP protocol, and AI_VMAPPED | AI_ADDRCONFIG (with perhaps more flags). Then allocate the socket for connection as determined by the ai_family Java, and, I believe "epollcat" do "early allocation" of the os socket, depending on the "java.net.IPv4prefer" There may be a clever way to do C-style "allocate socket just-in-time" in epollcat. That could also be With InetAddress.getByName concerns dispatched. The head-of-the-work-queue becomes There would be a "due bill" to figure out if this could get out of sync with SN 0.5.0 practice. I think there is a relatively expensive javalib way find the info. I think the "due bill" could be a second pass, as long as it is not forgotten. |
There are layers to "name server". getaddrinfo with AI_NUMERICHOST and/or AI_NUMERICSERVICE is used |
As a way to ground some of this discussion, I can create a WIP PR based on my earlier rapid-prototyping, our discussions That gives something concrete. |
Before we pause this discussion and I switch to an IPv6 WIP, could you I think I will somewhat easier if I at least understand I tried getting CI to print out its copy, but, rightly, |
If you want to manually edit epollcat/.github/workflows/ci.yml Lines 86 to 87 in 9f5fda0
|
Thank you for hosts file. That explains how ::1 showed up for localhost. Knowing the environment change brings me some relief. re: remove "Check workflow". Thank you. The inside of my left arm is filled with tattoos of Cats Effects IO notes, so I will Cheers What do you think about me switching to buff up my IPv6 rapid prototyping into a WIP PR? |
This would be fantastic! At this point I would say IPv6 is the last major issue. Once it is solved, and I confirm that CI is passing for the affected projects, I would like to publish official Scala Native releases for all the projects I've been working on (Cats Effect, FS2, http4s, Skunk, etc.). |
Nothing like a little |
Replacing it with
127.0.0.1
works however.The text was updated successfully, but these errors were encountered: