0

I want to add Authorization header for basic Authorization to my jetty-client request.

I am running two instances on same browser one is server one is client ,Java-8 is being used as a technology, No DB No Spring etc. using org.eclipse.jetty,jetty-websocket,version-8.1.15.v20140411.

I had a websocketEndPointManager class which contains the initialization method for both Server(dedicated class is CSWebsocket) and client(Cpwebsocket).

How can I achieve basic auth in my scenario where server maintains username and password is to matched in current session after its instance is ready, currently my setup able to perform upgrade to websocket but not basic

Snippet of client websocket start method where handshake occur :

  private void startCPWebSocket() throws Exception{
                 String uri ="";
           try {
            HandlerRegistry.register(this);
WebSocketClientFactory factory = new  WebSocketClientFactory();

Configuration configuration = TestSession.getConfiguration();
    uri = configuration.getSystemUnderTestEndpoint();
TestSession.getConfiguration().setToolURL("NA");
TestSession.getConfiguration().setSystemUnderTestEndpoint(uri);
factory.start();

WebSocketClient client = factory.newWebSocketClient();
client.setMaxIdleTime(24*60*60*1000);


client.open(new URI(uri.trim()),new CPWebSocket()).get(24*60*60,
                                       TimeUnit.SECONDS);
    LogUtils.logInfo("WebSocket URL : "+uri,true);
   }
            catch (ExecutionException e) {
  LogUtils.logError(e.getMessage(), e,false);
LogUtils.logWarn("Could not establish websocket connection.",true);
            //System.exit(0); 
            TestSession.setTerminated(true);
            throw e;
Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
AjaySom
  • 1
  • 2
  • [Jetty 8 websocket was deprecated and declared EOL (End of Life) years ago](https://www.eclipse.org/lists/jetty-announce/msg00069.html). It no longer supports the current WebSocket protocol standard properly (it will fail with various mobile networks, various ISPs, many backend websocket servers, etc). Please consider upgrading. – Joakim Erdfelt Feb 08 '19 at 12:58
  • Can we achieve the goal using custom headers .Javax websocket configurator is supported by jetty8 ? – AjaySom Feb 12 '19 at 05:10
  • The first stable release of javax.websocket support was in Jetty 9.2.0 – Joakim Erdfelt Feb 12 '19 at 16:35

0 Answers0