You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closing the websocket connection in onOpen should be possible.
Current Behavior
Calling conn.close() in public void WebSocketServer::onOpen(WebSocket conn, ClientHandshake handshake) leads to a NullPointerException. The socket is still closed correctly, but an error is logged.
Steps to Reproduce (for bugs)
Run a server which closes new connections right away in onOpen like below.
Error while reading from remote connection: java.lang.NullPointerException
java.lang.NullPointerException
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:214)
at org.java_websocket.server.WebSocketServer$WebSocketWorker.run(WebSocketServer.java:881)
Context
I'm trying to implement an authentication scheme for my websocket service using a token which gets passed to the websocket server in a cookie during the handshake. Rejecting the handshake in onWebsocketHandshakeReceivedAsServer isn't an option for me, because I can't destinguish between the server rejecting the connection and the server being offline in the browser.
I need to wait until the connection is open to validate the token and send a custom closecode if it's invalid.
Your Environment
Version used: 1.3.6
Java version: 1.8.0_152
Operating System and version: Windows 10 x64
The text was updated successfully, but these errors were encountered:
Expected Behavior
Closing the websocket connection in onOpen should be possible.
Current Behavior
Calling
conn.close()
inpublic void WebSocketServer::onOpen(WebSocket conn, ClientHandshake handshake)
leads to a NullPointerException. The socket is still closed correctly, but an error is logged.Steps to Reproduce (for bugs)
Debug log (for bugs)
Context
I'm trying to implement an authentication scheme for my websocket service using a token which gets passed to the websocket server in a cookie during the handshake. Rejecting the handshake in
onWebsocketHandshakeReceivedAsServer
isn't an option for me, because I can't destinguish between the server rejecting the connection and the server being offline in the browser.I need to wait until the connection is open to validate the token and send a custom
closecode
if it's invalid.Your Environment
The text was updated successfully, but these errors were encountered: