I've implemented this piece of code on my WebSocketServer:
public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket conn, Draft draft, ClientHandshake request) throws InvalidDataException {
ServerHandshakeBuilder builder = super.onWebsocketHandshakeReceivedAsServer(conn, draft, request);
if (!shouldAccept(request)) {
throw new InvalidDataException(CloseFrame.POLICY_VALIDATION, "Not accepted!");
}
return builder;
}
When an invalid handshake is sent by the client, nothing happens. The client doesn't close the connection nor connect.
I've implemented this piece of code on my WebSocketServer:
When an invalid handshake is sent by the client, nothing happens. The client doesn't close the connection nor connect.