Ubuntu 16.04 上的 Websockets

Ubuntu 16.04 上的 Websockets

我正在尝试创建一个不和谐bot,它需要能够连接到 websocket,但是,每当我尝试通过我的 java 代码连接到 websocket 时,它都会超时,但当我在我的个人电脑上运行它时,它可以正常工作。

错误:

java.lang.RuntimeException: java.net.ConnectException: Connection timed out
    at net.dv8tion.jda.requests.WebSocketClient.connect(WebSocketClient.java:199)
    at net.dv8tion.jda.requests.WebSocketClient.<init>(WebSocketClient.java:81)
    at net.dv8tion.jda.entities.impl.JDAImpl.login(JDAImpl.java:132)
    at net.dv8tion.jda.JDABuilder.buildAsync(JDABuilder.java:291)
    at net.dv8tion.jda.JDABuilder.buildBlocking(JDABuilder.java:312)
    at me.Swedz.pb.Main$1.run(Main.java:29)
    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
    at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
    at com.neovisionaries.ws.client.WebSocketFactory.createDirectRawSocket(WebSocketFactory.java:653)
    at com.neovisionaries.ws.client.WebSocketFactory.createRawSocket(WebSocketFactory.java:578)
    at com.neovisionaries.ws.client.WebSocketFactory.createSocket(WebSocketFactory.java:510)
    at com.neovisionaries.ws.client.WebSocketFactory.createSocket(WebSocketFactory.java:490)
    at com.neovisionaries.ws.client.WebSocketFactory.createSocket(WebSocketFactory.java:272)
    at com.neovisionaries.ws.client.WebSocketFactory.createSocket(WebSocketFactory.java:228)
    at net.dv8tion.jda.requests.WebSocketClient.connect(WebSocketClient.java:191)
    ... 10 more

主类:http://pastebin.com/raw/gKAG2dad

此代码旨在在 Minecraft 服务器上运行,因此 onEnable() 和 onDisable() 方法适用于此。(以及使用 BukkitRunnable 的选项)

编辑:我发现这只会发生有时...

相关内容