From kontakt at lukaslentner.de Thu Nov 22 04:52:38 2018 From: kontakt at lukaslentner.de (Lukas Lentner) Date: Thu, 22 Nov 2018 09:52:38 +0000 Subject: [undertow-dev] Forwarding initial websocket request Message-ID: I am trying to forward the initial websocket http request coming in via a Servlet filter with the forward method (I want to cut off the first path segment): final String requestUri = HttpServletRequest.class.cast(servletRequest).getRequestURI(); final String newRequestUri = requestUri.substring(requestUri.indexOf("/", 1)); servletRequest.getRequestDispatcher(newRequestUri).forward(servletRequest, servletResponse); The filter is triggered successfully, but the websocket is not initialized instead 404 is returned. Is this correct according to spec? How can I forward such requests? Thankx Lukas -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20181122/682e61d3/attachment-0001.html From marc.boorshtein at tremolosecurity.com Thu Nov 29 16:32:37 2018 From: marc.boorshtein at tremolosecurity.com (Marc Boorshtein) Date: Thu, 29 Nov 2018 16:32:37 -0500 Subject: [undertow-dev] Creating a websocket proxy with undertow Message-ID: Using the 1.4 series, I'm trying to handle upgrade and websockets. Looking at a few examples and the code I think what I need to do is: 1. add the WebSocketServlet to the right path 2. implement WebSocketConnectionCallback that will call my remote ws:// server Am I on the right track? I haven't found an example of doing this with undertow but found something similar with jetty ( https://github.com/chipster/chipster-web-server/blob/master/src/main/java/fi/csc/chipster/proxy/WebSocketProxyServlet.java) but I havne't found the same thing for undertow so any pointers would be appreciated. Thanks Marc Boorshtein -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20181129/c8a1035a/attachment.html From sdouglas at redhat.com Thu Nov 29 17:07:11 2018 From: sdouglas at redhat.com (Stuart Douglas) Date: Fri, 30 Nov 2018 09:07:11 +1100 Subject: [undertow-dev] Creating a websocket proxy with undertow In-Reply-To: References: Message-ID: The easiest way would probably be to use the JSR-356 API. You basically just make an @ServerEndpoint that connects to the remote endpoint, and then passes messages back and forth. The JSRWebSocketServer gives and example of how to setup the server endpoint. Stuart On Fri, Nov 30, 2018 at 8:34 AM Marc Boorshtein < marc.boorshtein at tremolosecurity.com> wrote: > Using the 1.4 series, I'm trying to handle upgrade and websockets. > Looking at a few examples and the code I think what I need to do is: > > 1. add the WebSocketServlet to the right path > 2. implement WebSocketConnectionCallback that will call my remote ws:// > server > > Am I on the right track? I haven't found an example of doing this with > undertow but found something similar with jetty ( > https://github.com/chipster/chipster-web-server/blob/master/src/main/java/fi/csc/chipster/proxy/WebSocketProxyServlet.java) > but I havne't found the same thing for undertow so any pointers would be > appreciated. > > Thanks > > > Marc Boorshtein > > > _______________________________________________ > undertow-dev mailing list > undertow-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/undertow-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20181130/435496c4/attachment.html From marc.boorshtein at tremolosecurity.com Fri Nov 30 14:41:14 2018 From: marc.boorshtein at tremolosecurity.com (Marc Boorshtein) Date: Fri, 30 Nov 2018 14:41:14 -0500 Subject: [undertow-dev] Creating a websocket proxy with undertow In-Reply-To: References: Message-ID: Thanks Stuart. I need to avoid annotations since this will be configured dynamically. I was wrong about the version, right now i'm on 2.0.9.Final. I'm trying to create a websocket proxy. I was able to get the ReceiveListener registered in Undertow and create a WebSocketClient. I'm trying to pipe the data from the client through Undertow to the server, starting with a Text message: @Override protected void onText(WebSocketChannel webSocketChannel, StreamSourceFrameChannel messageChannel) throws IOException { PooledByteBuffer b = pool.allocate(); ByteBuffer buffer = b.getBuffer(); while (messageChannel.read(buffer) > 0) { WebSockets.sendText(buffer, wsClient, null); } b.close(); } The message sent to the downstream websocket server isn't right though (and the server rejects it). The frame from wireshark just shows a buffer of "\000\000...". I think I'm close but I don't see an example of how to do this. Any suggestions or pointers would be greatly appreciated. Thanks Marc Boorshtein On Thu, Nov 29, 2018 at 5:07 PM Stuart Douglas wrote: > The easiest way would probably be to use the JSR-356 API. You basically > just make an @ServerEndpoint that connects to the remote endpoint, and then > passes messages back and forth. The JSRWebSocketServer gives and example of > how to setup the server endpoint. > > Stuart > > On Fri, Nov 30, 2018 at 8:34 AM Marc Boorshtein < > marc.boorshtein at tremolosecurity.com> wrote: > >> Using the 1.4 series, I'm trying to handle upgrade and websockets. >> Looking at a few examples and the code I think what I need to do is: >> >> 1. add the WebSocketServlet to the right path >> 2. implement WebSocketConnectionCallback that will call my remote ws:// >> server >> >> Am I on the right track? I haven't found an example of doing this with >> undertow but found something similar with jetty ( >> https://github.com/chipster/chipster-web-server/blob/master/src/main/java/fi/csc/chipster/proxy/WebSocketProxyServlet.java) >> but I havne't found the same thing for undertow so any pointers would be >> appreciated. >> >> Thanks >> >> >> Marc Boorshtein >> >> >> _______________________________________________ >> undertow-dev mailing list >> undertow-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/undertow-dev > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20181130/b99368e2/attachment.html