TakahikoKawasaki / nv-websocket-client

High-quality WebSocket client implementation in Java.
Apache License 2.0
2.03k stars 292 forks source link

Handshake failure with basic Authorization #244

Open Na2l opened 1 year ago

Na2l commented 1 year ago

adding header basic auth header to the websocket object causes server to close the connection imidietly with this warning messageL

Session 30 closed because of CloseReason: code [1002], reason [A fragmented control frame was received but control frames may not be fragmented]

String identity = userID + ":" + passwd; String encoded= Base64.encodeToString(identity.getBytes(), Base64.DEFAULT); webSocket.addHeader("Authorization", "Basic " + encoded);

The workaround is to instead of adding the basic auth header to add the user:pass to the request uri, i.e.: uri = new URI("wss://" + user+":" + pass+ :"443/websocket" );