This is my first post.I have seen some some answer for this question - Jetty 8.1.1 Websocket client handshake But using similar kind of solution didn't help me. The Client connects to the server and sends the message, but on the server side, the server is not authenticating client (invalid token) even tough I am sending the right token. I am not able to understand what I am missing. Same thing in Javascript is working but I have to implement it in Java.
Here is my sample client code. Any help will be greatly appreciated.Thanks!
public class JettyWebSocketClient {
public static void main(String[] args) throws Exception {
JettyWebSocketClient app = new JettyWebSocketClient();
app.test();
}
public void test() throws Exception {
ClientUpgradeRequest request = new ClientUpgradeRequest();
request.setHeader("Authorization", "xyz==");
WebSocketClient client = new WebSocketClient(new SslContextFactory());
MyWebSocket socket = new MyWebSocket();
client.start();
URI destUri = new URI("wss://xyz.com:4443/ws");
System.out.println("Connecting to " + destUri);
client.connect(socket, destUri, request);
socket.awaitClose(20, TimeUnit.SECONDS);
client.stop();
}
}