import java.io.IOException; import java.net.URI; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; import javax.websocket.ContainerProvider; import javax.websocket.DeploymentException; import javax.websocket.WebSocketContainer; public class Client { final static CountDownLatch messageLatch = new CountDownLatch(1); public static void main(String[] args) { try { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); String uri = "ws://echo.websocket.org:80/"; // String uri = "ws://pocketmsg.ru:8888/v1/auth/"; // String uri = "wss://pocketmsg.ru:8888/v1/ws/"; // String uri = "wss://pocketmsg.ru:8888"; System.out.println("Connecting to " + uri); container.connectToServer(MyClientEndpoint.class, URI.create(uri)); messageLatch.await(100, TimeUnit.SECONDS); } catch (DeploymentException | InterruptedException | IOException ex) { Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex); } } }