当前位置: 动力学知识库 > 问答 > 编程问答 >

java - WebSocketContainer.connectToServer seems to hang

问题描述:

When I try to make a websocket session through a Java application using WebSocketContainter.connectToServer everything seems to hang. I don't get any indication there was an exception, or that the connection was successfully made. My code doesn't execute past the connectToServer call.

 String DEFAULT_URI = "ws://blah/ws/test";

WebSocketContainer wsContainer = ContainerProvider.getWebSocketContainer();

Session session = wsContainer.connectToServer(MyClient.class, new URI(DEFAULT_URI));

//this line never gets executed. Session from above isn't returned nor is an error

System.out.println(session);

From this example, I'd expect some sort of connection error seeing that I'm trying to establish a connection to a websocket address that isn't valid. When using a valid ws address I also don't progress past getting the connection to return a session.

分享给朋友:
您可能感兴趣的文章:
随机阅读: