Slowpoke101 / FTBLaunch

Launcher for the FTB Mod Pack
182 stars 140 forks source link

IPv6 unable to connect to IPv6 only Servers #994

Closed joern-h closed 7 years ago

joern-h commented 7 years ago

Issue: You can't connect to a server wich uses IPv6 only

Steps to reproduce:

  1. Add a server that resolves only to IPv6 or using an IPv6 address.
  2. Try to connect.

Caused by:

The launcher disables IPv6 by:

arguments.add("-Djava.net.preferIPv4Stack=true"); in File src/main/java/net/ftb/minecraft/MCLauncher.java

How to fix it:

1: Simply remove this line or: Add a checkbox for IPv6 in the options to let us decide rather using IPv6 or IPv4 as simple as:

if(!useIPv6.isSelected()){ arguments.add("-Djava.net.preferIPv4Stack=true"); }

Little workaround wich is working too:

The only way i know to connect to IPv6 only servers is to add custom values:

-Djava.net.preferIPv4Stack=false -Djava.net.preferIPv6Stack=true

I compiled the FTB Launcher with arguments.add("-Djava.net.preferIPv4Stack=true"); commented out and i'm able to connect to IPv4 and IPv6 Servers.

Also check out https://bugs.mojang.com/browse/MC-3776 for better description of the problem.

Best regards, Joern2410

progwml6 commented 7 years ago

I think that the checkbox is going to be a better option for this for the time being, as i'm afraid causing unintended side effects removing it completely at this time.

Unfortunately, Oracle set this setting up in a piss poor manner, as it really should prefer ipv4 connections when both are available, but use ipv6 when you are connecting to something that has ipv6 only

jikuja commented 7 years ago

Did you try this solution with modpacks? I'm not sure if it works like described. Ref: https://github.com/MinecraftForge/MinecraftForge/blob/1.11.x/src/main/java/net/minecraftforge/fml/common/launcher/FMLTweaker.java#L50

joern-h commented 7 years ago

@jikuja I compiled the launcher with only comment out:

arguments.add("-Djava.net.preferIPv4Stack=true"); in File src/main/java/net/ftb/minecraft/MCLauncher.java

and im able to play modpack direwolf20 1.10.2 on my server wich has only a IPv6 address. Before with the unmodified launcher i wasn't able to play and got PROTOCOL FAMILY UNAVAILABLE error while try to connect.

System.setProperty("java.net.preferIPv4Stack", "true"); https://github.com/MinecraftForge/MinecraftForge/blob/1.11.x/src/main/java/net/minecraftforge/fml/common/launcher/FMLTweaker.java#L50

I think this dosen't affect the connection. the same line is also in the Main here: System.setProperty("java.net.preferIPv4Stack", "true"); https://github.com/Slowpoke101/FTBLaunch/blob/master/src/main/java/net/ftb/main/Main.java#L128

So i think this is for the launcher to download updates and i think forge does this too to download missing libraries ore something, but i'm not sure.

joern-h commented 7 years ago

I cloned the project and added the option for IPv6 with a checkbox. How can i give you my code? (Im new to Github :)"

progwml6 commented 7 years ago

via a pull request

jikuja commented 7 years ago

Let's talk about this issue before continuing:

1) JVM(greppep j8u72 source code) does not use property preferIPv6Stack how does using that fix the problem? Or is this feature of Netty?

1) Never mind. Correct defines are java.net.preferIPv4Stack and java.net.preferIPv6Addresses 2) Does command line defines override programmatically set system properties? (afaik forge will always set java.net.preferIPv4Stack to true for running MC process as soon as possible)

joern-h commented 7 years ago

@jikuja I dont know what have more priorities in Java, but the system property dosen't affect the connection with the server.