tyrus websockets ClientManager connectToServer'未收到握手响应'
如何在没有越来越多的守护进程和灰熊内核和灰熊工作线程创建的情况下重试连接。是否有调用 Session 或客户端来杀死/清理 Thread-1 到 4 以及 Grizzly-kernel 和 Grizzly-worker 线程?
示例 JAVA 主线,它永远尝试与可能未运行或定期重新启动的服务器建立并保持连接。
public void onClose(Session session, CloseReason closeReason) {
latch.countDown();
}
enter code here
public static void main(String[] args) {
while (true) {
latch = new CountDownLatch(1);
ClientManager client = ClientManager.createClient();
try {
client.connectToServer(wsListener.class, new URI("wss://<host>/ws"));
latch.await();
}
catch (DeploymentException e) {
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
break;
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
client = null;
latch = null;
// HERE... clean up
}
}