I've got a class that extends AsyncProxyServlet to do proxying with Jetty:
Server httpProxy = new Server();
ServletHolder servletHolder = new ServletHolder(TunnelProxyServlet.class);
HandlerCollection handlers = new HandlerCollection();
httpProxy.setHandler(handlers);
ServletContextHandler contextHandler = new ServletContextHandler(handlers, "/", ServletContextHandler.SESSIONS);
contextHandler.addServlet(servletHolder, "/*");
Now I'd like to add WebSocket support to this.
I tried this:
try {
WebSocketUpgradeFilter.configure(contextHandler);
NativeWebSocketServletContainerInitializer.configure(contextHandler, ((context, container) ->
{
container.addMapping("/*", (req, resp) -> new WebSocketProxy().getWebSocketConnectionListener());
}));
} catch (ServletException ex) {
Logger.getLogger(HttpProxy.class.getName()).log(Level.SEVERE, ex.getMessage());
}
But the code never reaches this point.
How can I do proxying with WebSockets?