I have a Java application that connects to a remote websocket server. As a client, I'm using the standard J2EE JSR356 WebSocket API:
Unfortunately, this is not exposed by JSR 356 - WebSocket API for Java. You will need to use implementation feature, such as HANDSHAKE_TIMEOUT in Tyrus (reference implementation). Other implementations will most likely have something similar.