我正在使用
编译组:'org.glassfish.tyrus.bundles',名称:'tyrus-standalone-client',版本:'1.13'
我的服务器已启动并运行,但我的客户端有时无法连接。出现以下错误。 这是一个聊天应用程序。
代码:
public void connect(final MessageHandler.Whole<String> messageHandler){
new Thread(new Runnable() {
@Override
public void run() {
try {
session = container.connectToServer(new Endpoint() {
@Override
public void onOpen(Session session, EndpointConfig config) {
session.addMessageHandler(messageHandler);
}
},ClientEndpointConfig.Builder.create().build(),URI.create(url));
} catch (DeploymentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
**StackTrace** : 03-28 09:31:02.023 17028-17604/com.biz.health.anycare W/System.err: javax.websocket.DeploymentException: Handshake response not received.
03-28 09:31:02.023 17028-17604/com.biz.health.anycare W/System.err: at org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:699)
03-28 09:31:02.023 17028-17604/com.biz.health.anycare W/System.err: at org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:717)
03-28 09:31:02.033 17028-17604/com.biz.health.anycare W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
03-28 09:31:02.033 17028-17604/com.biz.health.anycare W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-28 09:31:02.033 17028-17604/com.biz.health.anycare W/System.err: at org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:871)
03-28 09:31:02.033 17028-17604/com.biz.health.anycare W/System.err: at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:81)
03-28 09:31:02.033 17028-17604/com.biz.health.anycare W/System.err: at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:516)
03-28 09:31:02.033 17028-17604/com.biz.health.anycare W/System.err: at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:360)
03-28 09:31:02.033 17028-17604/com.biz.health.anycare W/System.err: at com.cooey.maya.WebSocketConnector$1.run(WebSocketConnector.java:48)
03-28 09:31:02.033 17028-17604/com.biz.health.anycare W/System.err: at java.lang.Thread.run(Thread.java:818)