Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
FULL PRODUCT VERSION : java version "10" 2018-03-20 Java(TM) SE Runtime Environment 18.3 (build 10+46) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10+46, mixed mode) ADDITIONAL OS VERSION INFORMATION : Darwin MacBook-Pro-de-Joel.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64 EXTRA RELEVANT SYSTEM CONFIGURATION : WiFi Interface: IPv4 DHCP Ethernet Interface: IPv4 DHCP, IPv6: fd00:c6a1:dea5:1::2 A DESCRIPTION OF THE PROBLEM : When I try to connect to IPv6 host using literal address it throws a NoRouteToHostException but using ping6 its works. In OS X Java always set a scope id in IPv6 addresses, but sometimes set a scope id for a invalid interface (without appropriated IPv6 address). STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Enable two network interfaces (Wifi and Ethernet) but only set IPv6 address to one. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - Correct connection to the host (no errors). ACTUAL - Receive a NoRouteToHostException. ERROR MESSAGES/STACK TRACES THAT OCCUR : java.net.NoRouteToHostException: No route to host (Host unreachable) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:400) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:243) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:225) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:402) at java.base/java.net.Socket.connect(Socket.java:591) at java.base/java.net.Socket.connect(Socket.java:540) at com.chaldeas.server/com.chaldeas.server.Main.main(Main.java:11) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- package com.chaldeas.server; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; public class Main { public static void main(String [] args) { try { Socket socket = new Socket(); socket.connect(new InetSocketAddress("[fd00:c6a1:dea5:1::3]", 80)); } catch (IOException e) { e.printStackTrace(); } } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : I found than in OS X, Java in socketConnect native method in PlainSocketImpl class always set a default scope id to the first available interface; in this case is the Wireless interface but it hasn't a valid IPv6 address, if I put a IPv6 address in the interface, the code works, but the interface must be in the same logical network.