-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIPv6Test.java
More file actions
34 lines (27 loc) · 1.48 KB
/
IPv6Test.java
File metadata and controls
34 lines (27 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
public class IPv6Test {
public static void main(String[] args) {
// This is a well-known IPv6-only hostname provided by Google.
String host = "ipv6.google.com";
int port = 80; // Standard web port.
System.out.println("Attempting to connect to " + host + " on port " + port + " using IPv6...");
try {
// Force the JVM to prefer IPv6 addresses.
System.setProperty("java.net.preferIPv6Addresses", "true");
SocketChannel socketChannel = SocketChannel.open();
socketChannel.socket().connect(new InetSocketAddress(host, port), 5000); // 5-second timeout
if (socketChannel.isConnected()) {
System.out.println("\nSUCCESS!");
System.out.println("Java was able to successfully make an IPv6 connection from this machine.");
System.out.println("This proves the issue is likely not with the server's core network configuration.");
socketChannel.close();
}
} catch (Exception e) {
System.out.println("\nFAILURE!");
System.out.println("Java was UNABLE to make an IPv6 connection from this machine.");
System.out.println("This is the root cause of the problem. Lavalink's IP rotation cannot function.");
System.out.println("Error details: " + e.getMessage());
}
}
}