From dennis at gesker.com Tue Oct 6 15:15:05 2015 From: dennis at gesker.com (Dennis Gesker) Date: Tue, 6 Oct 2015 13:15:05 -0600 Subject: [undertow-dev] Different Session Ids Message-ID: Hello List: I'm trying to use a websocket in Wildfly 10.0.0.CR2 from a Java SE client. It's a pretty basic socket (a little more than just an echo). I'm sending a string to the WS on the server. *However, the session id logged on WildFly and the session id on my Java SE Client do not match*. 2015-10-06 12:31:28 INFO com.alamon.socket.GetCfgRoleWS - ServerSide >>> Connected to ... *t9Y2a4kra35JpISc1s8F0qelNhoQ8mB7I_D3vTl4* 2015-10-06 12:31:28 INFO com.alamon.socket.GetCfgRoleWS - ServerSide >>> *got: 6* : t9Y2a4kra35JpISc1s8F0qelNhoQ8mB7I_D3vTl4 2015-10-06 12:31:29 INFO stdout - {"id":6,"name":"inspector","description":"inspector","enabled":true,"created":1444156117341,"modified":1444156117341} 2015-10-06 12:31:29 INFO com.alamon.socket.GetCfgRoleWS - ServerSide >>> Session t9Y2a4kra35JpISc1s8F0qelNhoQ8mB7I_D3vTl4 closed because of CloseReason[1000] ClientSide >>> Session *6uT2VhsWOF8Kc5eMboHCybXQ02v1duV9MnhW8KMl* closed because of CloseReason[1000] The value I'm sending to the server (6 as a String) is showing up on the server side but I'm not getting a response back. I'm guessing because the session id's don't match. But, neither the Java SE client or the Wildfly server are throwing any errors. The client side seems pretty straight forward: websocketServer = "http://localhost:8080/web/getCfgRoleWS"; websocketServerURI = new URI(websocketServer); webSocketContainer = ContainerProvider.getWebSocketContainer(); webSocketSession = webSocketContainer.connectToServer(this.getClass(), websocketServerURI); // And after checking that the webSocketSession is not null or closed: webSocketSession.getBasicRemote().sendText(id.toString()); Environment-- Client: JDK_1.8.0_60, Undertow 1.3.0.CR2 Server: JDK_1.8.0_60, Wildfly-10.0.0.CR2 I would welcome any hints or help that you can offer. Cordially, Dennis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151006/fda35b0c/attachment.html From sdouglas at redhat.com Wed Oct 7 07:27:58 2015 From: sdouglas at redhat.com (Stuart Douglas) Date: Wed, 7 Oct 2015 07:27:58 -0400 (EDT) Subject: [undertow-dev] Different Session Ids In-Reply-To: References: Message-ID: <586938909.28377672.1444217278317.JavaMail.zimbra@redhat.com> I'm really not clear what you are doing here? Are you expecting that Session.getId() on the server side to have some specific meaning? >From the Javadoc: " Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the web socket implementation and is implementation dependent." Stuart ----- Original Message ----- > From: "Dennis Gesker" > To: undertow-dev at lists.jboss.org > Sent: Tuesday, 6 October, 2015 9:15:05 PM > Subject: [undertow-dev] Different Session Ids > > Hello List: > > I'm trying to use a websocket in Wildfly 10.0.0.CR2 from a Java SE client. > > It's a pretty basic socket (a little more than just an echo). I'm sending a > string to the WS on the server. However, the session id logged on WildFly > and the session id on my Java SE Client do not match . > > > 2015-10-06 12:31:28 INFO com.alamon.socket.GetCfgRoleWS - ServerSide >>> > Connected to ... t9Y2a4kra35JpISc1s8F0qelNhoQ8mB7I_D3vTl4 > 2015-10-06 12:31:28 INFO com.alamon.socket.GetCfgRoleWS - ServerSide >>> got: > 6 : t9Y2a4kra35JpISc1s8F0qelNhoQ8mB7I_D3vTl4 > 2015-10-06 12:31:29 INFO stdout - > {"id":6,"name":"inspector","description":"inspector","enabled":true,"created":1444156117341,"modified":1444156117341} > 2015-10-06 12:31:29 INFO com.alamon.socket.GetCfgRoleWS - ServerSide >>> > Session t9Y2a4kra35JpISc1s8F0qelNhoQ8mB7I_D3vTl4 closed because of > CloseReason[1000] > > ClientSide >>> Session 6uT2VhsWOF8Kc5eMboHCybXQ02v1duV9MnhW8KMl closed > because of CloseReason[1000] > > The value I'm sending to the server (6 as a String) is showing up on the > server side but I'm not getting a response back. I'm guessing because the > session id's don't match. But, neither the Java SE client or the Wildfly > server are throwing any errors. > > The client side seems pretty straight forward: > websocketServer = " http://localhost:8080/web/getCfgRoleWS "; > websocketServerURI = new URI(websocketServer); > webSocketContainer = ContainerProvider.getWebSocketContainer(); > webSocketSession = webSocketContainer.connectToServer(this.getClass(), > websocketServerURI); > // And after checking that the webSocketSession is not null or closed: > webSocketSession.getBasicRemote().sendText(id.toString()); > > Environment-- > Client: JDK_1.8.0_60, Undertow 1.3.0.CR2 > Server: JDK_1.8.0_60, Wildfly-10.0.0.CR2 > > I would welcome any hints or help that you can offer. > > Cordially, > Dennis > > > > > > > > > > _______________________________________________ > undertow-dev mailing list > undertow-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/undertow-dev From greg.hellings at gmail.com Thu Oct 8 12:41:03 2015 From: greg.hellings at gmail.com (Greg Hellings) Date: Thu, 8 Oct 2015 11:41:03 -0500 Subject: [undertow-dev] HttpServerExchange Message-ID: I'm trying to mock out the HttpServerExchange object in my tests, but I apparently cannot do so because the class is declared final. Why is it final? Does that give Undertow anything beneficial? If there's good reason to not remove the final, I can just wrap the object in a proxy class that's not final, but I'd rather not do that just to get around limitations in mocking. Another alternative would be for me to skip unit tests on the handler methods and leverage integration tests.But there are sometimes bits of logic in the handler that I want to Unit Test directly. Any help would be appreciated. --Greg From gregcsco at gmail.com Fri Oct 9 10:05:43 2015 From: gregcsco at gmail.com (Greg Shrack) Date: Fri, 9 Oct 2015 08:05:43 -0600 Subject: [undertow-dev] corrupted messages? Message-ID: I'm seeing an inconsistent problem where some messages are corrupted. We're sending serialized objects over websockets, and are seeing some corrupted messages with larger messages and sometimes when sending more quickly. We've testing with a number of versions including undertow 1.1.8.Final, but was seeing the same issue with newer versions as well. Wireshark appears to show the corrupted data on the client side. I've included sample code. The server creates a handler at localhost:6025 and then listens for messages. When a message is received it checks the message against an expected pattern and prints out any bytes that don?t match. The client connects to the server and sends five 5000 byte messages one second apart. On my machine at least one of the 5 messages would come across with some corrupted data. I narrowed this down some - if the message is 2930 bytes, it appears to get through. At 2931, I start seeing some corruption. Using same test code with 1000 byte messages I was able to send 10000 messages with no sleep in between each send and all messages went through fine. Hopefully I'm missing something obvious. Thanks. ----- import io.undertow.Handlers; import io.undertow.Undertow; import io.undertow.websockets.WebSocketConnectionCallback; import io.undertow.websockets.core.AbstractReceiveListener; import io.undertow.websockets.core.BufferedBinaryMessage; import io.undertow.websockets.core.WebSocketChannel; import io.undertow.websockets.core.WebSockets; import io.undertow.websockets.spi.WebSocketHttpExchange; import org.xnio.Pooled; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Arrays; public class WebsocketTestServer { public WebsocketTestServer() { Undertow server = Undertow.builder() .addHttpListener(6025, "localhost") .setHandler(Handlers.pathTemplate().add("test", Handlers.websocket(new TestHandler()))) .build(); server.start(); System.out.println("Server Started"); } private class TestHandler extends AbstractReceiveListener implements WebSocketConnectionCallback { @Override public void onConnect(WebSocketHttpExchange webSocketHttpExchange, WebSocketChannel webSocketChannel) { System.out.println("Client connected"); webSocketChannel.getReceiveSetter().set(this); webSocketChannel.resumeReceives(); } @Override protected void onFullBinaryMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException { try (Pooled pooled = message.getData()) { ByteBuffer[] buffers = pooled.getResource(); ByteBuffer bb = (buffers.length == 1) ? buffers[0] : WebSockets.mergeBuffers(buffers); if (bb.limit() > 0) { checkData(bb); } } } } // Checks data against expected pattern public static void checkData(ByteBuffer data) { long messageId = data.getLong(0); for (int i = Long.BYTES; i < data.limit(); i++) { byte expected = (byte) (i%256); byte actual = data.get(i); if (actual != expected) { System.err.println("**** Corrupted data for message " + messageId + " byte " + i + " expected " + expected + " but was " + actual); } } } public static void main(String[] args) throws InterruptedException { WebsocketTestServer server = new WebsocketTestServer(); while (true) { Thread.sleep(5000); } } } ---------- import javax.websocket.ClientEndpoint; import javax.websocket.ContainerProvider; import javax.websocket.OnOpen; import javax.websocket.Session; import javax.websocket.WebSocketContainer; import java.net.URI; import java.nio.ByteBuffer; @ClientEndpoint public class WebsocketTestClient { private Session session; public WebsocketTestClient() { try { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); container.connectToServer(this, URI.create("ws://localhost:6025/test")); } catch (Exception e) { e.printStackTrace(); } } @OnOpen public void onOpen(Session session) { System.out.println("Session opened"); this.session = session; } public void sendData(long index) { try { session.getBasicRemote().sendBinary(createTestData(index)); } catch (Exception e) { e.printStackTrace(); } } public static final ByteBuffer createTestData(long messageId) { ByteBuffer buffer = ByteBuffer.allocate(5000); buffer.putLong(messageId); for(int i=Long.BYTES; i< buffer.limit(); i++) { buffer.put((byte) (i%256)); } buffer.flip(); return buffer; } public static void main(String[] args) throws InterruptedException { WebsocketTestClient client = new WebsocketTestClient(); Thread.sleep(1000); for(int i=0; i<5; i++) { System.out.println("Sending " + i); client.sendData(i); Thread.sleep(1000); } System.out.println("Done"); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151009/637e16a4/attachment-0001.html From peter.royal at pobox.com Fri Oct 9 10:39:37 2015 From: peter.royal at pobox.com (peter royal) Date: Fri, 09 Oct 2015 09:39:37 -0500 Subject: [undertow-dev] corrupted messages? In-Reply-To: References: Message-ID: <8f1c3b222219ee43f1290b4b966e7e17@pobox.com> On 2015-10-09 09:05, Greg Shrack wrote: > I'm seeing an inconsistent problem where some messages are corrupted. We're sending serialized objects over websockets, and are seeing some corrupted messages with larger messages and sometimes when sending more quickly. We've testing with a number of versions including undertow 1.1.8.Final, but was seeing the same issue with newer versions as well. Wireshark appears to show the corrupted data on the client side Is it this stack trace? ava.io.IOException: io.undertow.websockets.core.WebSocketFrameCorruptedException: UT002010: Received continuation data frame outside fragmented message at io.undertow.websockets.core.WebSocketChannel.parseFrame(WebSocketChannel.java:184) ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] at io.undertow.server.protocol.framed.AbstractFramedChannel.receive(AbstractFramedChannel.java:340) ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:38) [undertow-core-1.2.8.Final.jar:1.2.8.Final] at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:33) [undertow-core-1.2.8.Final.jar:1.2.8.Final] at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.1.Final.jar:3.3.1.Final] at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:775) [undertow-core-1.2.8.Final.jar:1.2.8.Final] at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:763) [undertow-core-1.2.8.Final.jar:1.2.8.Final] at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) [xnio-api-3.3.1.Final.jar:3.3.1.Final] at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) [xnio-api-3.3.1.Final.jar:3.3.1.Final] at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88) [xnio-nio-3.3.1.Final.jar:3.3.1.Final] at org.xnio.nio.WorkerThread.run(WorkerThread.java:539) [xnio-nio-3.3.1.Final.jar:3.3.1.Final] Caused by: io.undertow.websockets.core.WebSocketFrameCorruptedException: UT002010: Received continuation data frame outside fragmented message at io.undertow.websockets.core.protocol.version07.WebSocket07Channel$WebSocketFrameHeader.validateDataFrame(WebSocket07Channel.java:418) ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] at io.undertow.websockets.core.protocol.version07.WebSocket07Channel$WebSocketFrameHeader.handle(WebSocket07Channel.java:267) ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] at io.undertow.websockets.core.WebSocketChannel.parseFrame(WebSocketChannel.java:174) ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] ... 10 common frames omitted I intermittently get the above with 1.2. I helped refactor the websocket implementation in 1.3 and it should (hopefully) not exhibit that. I haven't pushed it into my production applications yet though. Have you tested one of the 1.3 candidates? -pete -- (peter.royal|osi)@pobox.com - http://fotap.org/~osi [1] Links: ------ [1] http://fotap.org/~osi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151009/eedaf042/attachment.html From gregcsco at gmail.com Fri Oct 9 10:49:22 2015 From: gregcsco at gmail.com (Greg) Date: Fri, 09 Oct 2015 08:49:22 -0600 Subject: [undertow-dev] corrupted messages? In-Reply-To: <8f1c3b222219ee43f1290b4b966e7e17@pobox.com> References: <8f1c3b222219ee43f1290b4b966e7e17@pobox.com> Message-ID: <1504d13e950.2767.04e88ff03bf9c03035143a2e55c593c1@gmail.com> We don't see an exception. The received data simply doesn't match the data sent. On October 9, 2015 8:39:38 AM peter royal wrote: > > > On 2015-10-09 09:05, Greg Shrack wrote: > >> I'm seeing an inconsistent problem where some messages are corrupted. We're >> sending serialized objects over websockets, and are seeing some corrupted >> messages with larger messages and sometimes when sending more quickly. >> We've testing with a number of versions including undertow 1.1.8.Final, but >> was seeing the same issue with newer versions as well. Wireshark appears to >> show the corrupted data on the client side > > Is it this stack trace? > > ava.io.IOException: > io.undertow.websockets.core.WebSocketFrameCorruptedException: UT002010: > Received continuation data frame outside fragmented message > at > io.undertow.websockets.core.WebSocketChannel.parseFrame(WebSocketChannel.java:184) > ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] > at > io.undertow.server.protocol.framed.AbstractFramedChannel.receive(AbstractFramedChannel.java:340) > ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] > at > io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:38) > [undertow-core-1.2.8.Final.jar:1.2.8.Final] > at > io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:33) > [undertow-core-1.2.8.Final.jar:1.2.8.Final] > at > org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) > [xnio-api-3.3.1.Final.jar:3.3.1.Final] > at > io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:775) > [undertow-core-1.2.8.Final.jar:1.2.8.Final] > at > io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:763) > [undertow-core-1.2.8.Final.jar:1.2.8.Final] > at > org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) > [xnio-api-3.3.1.Final.jar:3.3.1.Final] > at > org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) > [xnio-api-3.3.1.Final.jar:3.3.1.Final] > at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88) > [xnio-nio-3.3.1.Final.jar:3.3.1.Final] > at org.xnio.nio.WorkerThread.run(WorkerThread.java:539) > [xnio-nio-3.3.1.Final.jar:3.3.1.Final] > Caused by: io.undertow.websockets.core.WebSocketFrameCorruptedException: > UT002010: Received continuation data frame outside fragmented message > at > io.undertow.websockets.core.protocol.version07.WebSocket07Channel$WebSocketFrameHeader.validateDataFrame(WebSocket07Channel.java:418) > ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] > at > io.undertow.websockets.core.protocol.version07.WebSocket07Channel$WebSocketFrameHeader.handle(WebSocket07Channel.java:267) > ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] > at > io.undertow.websockets.core.WebSocketChannel.parseFrame(WebSocketChannel.java:174) > ~[undertow-core-1.2.8.Final.jar:1.2.8.Final] > ... 10 common frames omitted > > I intermittently get the above with 1.2. I helped refactor the websocket > implementation in 1.3 and it should (hopefully) not exhibit that. I > haven't pushed it into my production applications yet though. > > Have you tested one of the 1.3 candidates? > > -pete > > -- > (peter.royal|osi)@pobox.com - http://fotap.org/~osi [1] > > > Links: > ------ > [1] http://fotap.org/~osi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151009/a239ed26/attachment.html From peter.royal at pobox.com Fri Oct 9 10:51:23 2015 From: peter.royal at pobox.com (peter royal) Date: Fri, 09 Oct 2015 09:51:23 -0500 Subject: [undertow-dev] corrupted messages? In-Reply-To: <1504d13e950.2767.04e88ff03bf9c03035143a2e55c593c1@gmail.com> References: <8f1c3b222219ee43f1290b4b966e7e17@pobox.com> <1504d13e950.2767.04e88ff03bf9c03035143a2e55c593c1@gmail.com> Message-ID: <69b2b00657a9bdd5a78fc0337d3a5f45@pobox.com> On 2015-10-09 09:49, Greg wrote: > We don't see an exception. The received data simply doesn't match the data sent. Gotcha. Do you see this on the fresh 1.3.0.Final ? -pete -- (peter.royal|osi)@pobox.com - http://fotap.org/~osi [1] Links: ------ [1] http://fotap.org/~osi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151009/db00c333/attachment.html From melghaouat at gmail.com Wed Oct 14 06:22:20 2015 From: melghaouat at gmail.com (Mohammed ElGhaouat) Date: Wed, 14 Oct 2015 12:22:20 +0200 Subject: [undertow-dev] Resizing undertow thread pool size dynamically In-Reply-To: References: <779237744.346643.1439369723927.JavaMail.zimbra@redhat.com> Message-ID: Hello, I would like to share with you some more details about our situation. We are using some big machines that are shared by many software(many Wildfly instances, Databases, ERPs ..) If i don't set pools sizes i end up with big pools as the default size is dependent on the number of CPU cores and out system administrator is complaining about the OS spending time checking if the threads have something to do and this impact the other softwares installed on the same machine. If I set a small pool size which could sufficient in the 90% of time, i am afraid that Wildfly couldn't handle the 10% of time when the applications are used by a large number of user. Is there any workaround or are you planning to let the user to set a specific ThreadPoolExecutor ? so we can evict idle threads Thanks, Mohammed. On Wed, Aug 12, 2015 at 11:03 AM, Mohammed ElGhaouat wrote: > I am using Wildfly. > > Thanks, > > Mohammed. > > On Wed, Aug 12, 2015 at 10:55 AM, Stuart Douglas > wrote: > >> Are you using Wildfly or embedded Undertow? >> >> If it is the later you can just use >> io.undertow.servlet.api.DeploymentInfo#setExecutor to use whatever executor >> implementation you want. >> >> The reason why most executors don't reduce the number is because there is >> generally very little point, a parked thread is generally very cheap, while >> creating new threads is relatively expensive. >> >> Stuart >> >> ----- Original Message ----- >> > From: "Mohammed ElGhaouat" >> > To: "Jason Greene" >> > Cc: undertow-dev at lists.jboss.org >> > Sent: Wednesday, 12 August, 2015 6:19:11 PM >> > Subject: Re: [undertow-dev] Resizing undertow thread pool size >> dynamically >> > >> > We are using the servlet API and I am referring to worker pool. Simply >> we >> > don't want keeping bunch of idle threads in the JVM consuming some >> resources >> > without doing any thing useful. >> > >> > So with the bounded queue executor, when the value of the >> task-max-threads >> > parameter is reached, the number of threads in the worker pool couldn't >> be >> > decreased ? >> > >> > Thank you. >> > >> > >> > Mohammed. >> > >> > On Tue, Aug 11, 2015 at 9:50 PM, Jason Greene < jason.greene at redhat.com >> > >> > wrote: >> > >> > >> > >> > > On Aug 11, 2015, at 4:42 AM, Mohammed ElGhaouat < >> melghaouat at gmail.com > >> > > wrote: >> > > >> > > >> > > Hi, >> > > >> > > I would like to know if there is a way to make undertow reducing the >> size >> > > of the thread pool when the server is less loaded. Is there any >> > > parameter(or other way) that make an idle thread die after some >> inactivity >> > > time ? >> > >> > >> > Are you referring to the worker pool or the I/O pool? The I/O pool is >> special >> > and is fixed. The worker pool currently uses a JDK ThreadPoolExecutor >> with >> > an unbounded queue which is a behavior pattern typically desired for web >> > servers. That?s not pluggable at the moment, but it could be possible. >> > >> > If you are using the HttpHandler APIs, there is a method on >> > HttpServerDispatch that allows you to use your own custom executor for >> > blocking tasks (which would allow you to tune the default worker task >> pool >> > very small). If you are using servlet APIs though that uses the standard >> > pools we provide. >> > >> > Is there a particular reason you want to kill idle threads? Threads are >> cheap >> > unless you are storing massive amounts of thread local data. >> > >> > -- >> > Jason T. Greene >> > WildFly Lead / JBoss EAP Platform Architect >> > JBoss, a division of Red Hat >> > >> > >> > >> > _______________________________________________ >> > 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/20151014/89d14ac0/attachment-0001.html From sdouglas at redhat.com Sat Oct 17 04:54:01 2015 From: sdouglas at redhat.com (Stuart Douglas) Date: Sat, 17 Oct 2015 04:54:01 -0400 (EDT) Subject: [undertow-dev] corrupted messages? In-Reply-To: References: Message-ID: <300683561.32971583.1445072041963.JavaMail.zimbra@redhat.com> I have not been able to reproduce this. What OS are you using? Have you been able to reproduce it on different machines? Stuart ----- Original Message ----- > From: "Greg Shrack" > To: undertow-dev at lists.jboss.org > Sent: Friday, 9 October, 2015 4:05:43 PM > Subject: [undertow-dev] corrupted messages? > > > > I'm seeing an inconsistent problem where some messages are corrupted. We're > sending serialized objects over websockets, and are seeing some corrupted > messages with larger messages and sometimes when sending more quickly. We've > testing with a number of versions including undertow 1.1.8.Final, but was > seeing the same issue with newer versions as well. Wireshark appears to show > the corrupted data on the client side. > > > > > I've included sample code. The server creates a handler at localhost:6025 and > then listens for messages. When a message is received it checks the message > against an expected pattern and prints out any bytes that don?t match. > > > > > > The client connects to the server and sends five 5000 byte messages one > second apart. On my machine at least one of the 5 messages would come across > with some corrupted data. I narrowed this down some - if the message is 2930 > bytes, it appears to get through. At 2931, I start seeing some corruption. > Using same test code with 1000 byte messages I was able to send 10000 > messages with no sleep in between each send and all messages went through > fine. > > > > > > Hopefully I'm missing something obvious. Thanks. > > > > > ----- > > > > > import io.undertow.Handlers; > > import io.undertow.Undertow; > > import io.undertow.websockets.WebSocketConnectionCallback; > > import io.undertow.websockets.core.AbstractReceiveListener; > > import io.undertow.websockets.core.BufferedBinaryMessage; > > import io.undertow.websockets.core.WebSocketChannel; > > import io.undertow.websockets.core.WebSockets; > > import io.undertow.websockets.spi.WebSocketHttpExchange; > > import org.xnio.Pooled; > > > > > import java.io.IOException; > > import java.nio.ByteBuffer; > > import java.util.Arrays; > > > > > public class WebsocketTestServer > > { > > public WebsocketTestServer() > > { > > Undertow server = Undertow.builder() > > .addHttpListener(6025, "localhost") > > .setHandler(Handlers.pathTemplate().add("test", Handlers.websocket(new > TestHandler()))) > > .build(); > > > > > server.start(); > > System.out.println("Server Started"); > > } > > > > > private class TestHandler extends AbstractReceiveListener implements > WebSocketConnectionCallback > > { > > @Override > > public void onConnect(WebSocketHttpExchange webSocketHttpExchange, > WebSocketChannel webSocketChannel) > > { > > System.out.println("Client connected"); > > webSocketChannel.getReceiveSetter().set(this); > > webSocketChannel.resumeReceives(); > > } > > > > > @Override > > protected void onFullBinaryMessage(WebSocketChannel channel, > BufferedBinaryMessage message) throws IOException > > { > > try (Pooled pooled = message.getData()) > > { > > ByteBuffer[] buffers = pooled.getResource(); > > ByteBuffer bb = (buffers.length == 1) ? buffers[0] : > WebSockets.mergeBuffers(buffers); > > if (bb.limit() > 0) > > { > > checkData(bb); > > } > > } > > } > > } > > > > > // Checks data against expected pattern > > public static void checkData(ByteBuffer data) > > { > > long messageId = data.getLong(0); > > for (int i = Long.BYTES; i < data.limit(); i++) > > { > > byte expected = (byte) (i%256); > > byte actual = data.get(i); > > > > > if (actual != expected) > > { > > System.err.println("**** Corrupted data for message " + messageId + " byte " > + i + " expected " + expected + " but was " + actual); > > } > > } > > } > > > > > > > > public static void main(String[] args) throws InterruptedException > > { > > WebsocketTestServer server = new WebsocketTestServer(); > > > > > while (true) > > { > > Thread.sleep(5000); > > } > > } > > > > } > > ---------- > > import javax.websocket.ClientEndpoint; > import javax.websocket.ContainerProvider; > import javax.websocket.OnOpen; > import javax.websocket.Session; > import javax.websocket.WebSocketContainer; > import java.net.URI; > import java.nio.ByteBuffer; > > @ClientEndpoint > public class WebsocketTestClient > { > private Session session; > > public WebsocketTestClient() > { > try > { > WebSocketContainer container = ContainerProvider.getWebSocketContainer(); > container.connectToServer(this, URI.create("ws://localhost:6025/test")); > } > catch (Exception e) > { > e.printStackTrace(); > } > } > > @OnOpen > public void onOpen(Session session) > { > System.out.println("Session opened"); > this.session = session; > } > > public void sendData(long index) > { > try > { > session.getBasicRemote().sendBinary(createTestData(index)); > } > catch (Exception e) > { > e.printStackTrace(); > } > } > > public static final ByteBuffer createTestData(long messageId) > { > ByteBuffer buffer = ByteBuffer.allocate(5000); > buffer.putLong(messageId); > for(int i=Long.BYTES; i< buffer.limit(); i++) > { > buffer.put((byte) (i%256)); > } > buffer.flip(); > > return buffer; > } > > public static void main(String[] args) throws InterruptedException > { > WebsocketTestClient client = new WebsocketTestClient(); > Thread.sleep(1000); > > for(int i=0; i<5; i++) > { > System.out.println("Sending " + i); > client.sendData(i); > Thread.sleep(1000); > } > System.out.println("Done"); > } > } > > > > > > > > > > > > _______________________________________________ > undertow-dev mailing list > undertow-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/undertow-dev From bulutaras at gmail.com Sat Oct 17 06:54:37 2015 From: bulutaras at gmail.com (Bulut Aras) Date: Sat, 17 Oct 2015 13:54:37 +0300 Subject: [undertow-dev] webjars usage Message-ID: Hi, I don't know if this is the right place but I have problems setting up webjars in a maven project with undertow. I added dependencies to the pom.xml. But can't figure out how to set up Resource/File handler. Thanks in advance. From sdouglas at redhat.com Sat Oct 17 09:01:01 2015 From: sdouglas at redhat.com (Stuart Douglas) Date: Sat, 17 Oct 2015 09:01:01 -0400 (EDT) Subject: [undertow-dev] Resizing undertow thread pool size dynamically In-Reply-To: References: <779237744.346643.1439369723927.JavaMail.zimbra@redhat.com> Message-ID: <1485621145.32986999.1445086861898.JavaMail.zimbra@redhat.com> Like I said, you can use any thread pool you want if you modify it using a ServletExtension. Code looks like: public class MyExtension implements ServletExtension { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { Executor myThreadPool = {my thread pool}; deploymentInfo.setExecutor(myThreadPool); } } Then add a META-INF/services entry for the extension. Stuart ----- Original Message ----- > From: "Mohammed ElGhaouat" > To: "Stuart Douglas" > Cc: "Jason Greene" , undertow-dev at lists.jboss.org > Sent: Wednesday, 14 October, 2015 12:22:20 PM > Subject: Re: [undertow-dev] Resizing undertow thread pool size dynamically > > Hello, > > I would like to share with you some more details about our situation. We > are using some big machines that are shared by many software(many Wildfly > instances, Databases, ERPs ..) If i don't set pools sizes i end up with big > pools as the default size is dependent on the number of CPU cores and out > system administrator is complaining about the OS spending time checking if > the threads have something to do and this impact the other softwares > installed on the same machine. If I set a small pool size which could > sufficient in the 90% of time, i am afraid that Wildfly couldn't handle > the 10% of time when the applications are used by a large number of user. > > Is there any workaround or are you planning to let the user to set a > specific ThreadPoolExecutor ? so we can evict idle threads > > > Thanks, > > Mohammed. > > > On Wed, Aug 12, 2015 at 11:03 AM, Mohammed ElGhaouat > wrote: > > > I am using Wildfly. > > > > Thanks, > > > > Mohammed. > > > > On Wed, Aug 12, 2015 at 10:55 AM, Stuart Douglas > > wrote: > > > >> Are you using Wildfly or embedded Undertow? > >> > >> If it is the later you can just use > >> io.undertow.servlet.api.DeploymentInfo#setExecutor to use whatever > >> executor > >> implementation you want. > >> > >> The reason why most executors don't reduce the number is because there is > >> generally very little point, a parked thread is generally very cheap, > >> while > >> creating new threads is relatively expensive. > >> > >> Stuart > >> > >> ----- Original Message ----- > >> > From: "Mohammed ElGhaouat" > >> > To: "Jason Greene" > >> > Cc: undertow-dev at lists.jboss.org > >> > Sent: Wednesday, 12 August, 2015 6:19:11 PM > >> > Subject: Re: [undertow-dev] Resizing undertow thread pool size > >> dynamically > >> > > >> > We are using the servlet API and I am referring to worker pool. Simply > >> we > >> > don't want keeping bunch of idle threads in the JVM consuming some > >> resources > >> > without doing any thing useful. > >> > > >> > So with the bounded queue executor, when the value of the > >> task-max-threads > >> > parameter is reached, the number of threads in the worker pool couldn't > >> be > >> > decreased ? > >> > > >> > Thank you. > >> > > >> > > >> > Mohammed. > >> > > >> > On Tue, Aug 11, 2015 at 9:50 PM, Jason Greene < jason.greene at redhat.com > >> > > >> > wrote: > >> > > >> > > >> > > >> > > On Aug 11, 2015, at 4:42 AM, Mohammed ElGhaouat < > >> melghaouat at gmail.com > > >> > > wrote: > >> > > > >> > > > >> > > Hi, > >> > > > >> > > I would like to know if there is a way to make undertow reducing the > >> size > >> > > of the thread pool when the server is less loaded. Is there any > >> > > parameter(or other way) that make an idle thread die after some > >> inactivity > >> > > time ? > >> > > >> > > >> > Are you referring to the worker pool or the I/O pool? The I/O pool is > >> special > >> > and is fixed. The worker pool currently uses a JDK ThreadPoolExecutor > >> with > >> > an unbounded queue which is a behavior pattern typically desired for web > >> > servers. That?s not pluggable at the moment, but it could be possible. > >> > > >> > If you are using the HttpHandler APIs, there is a method on > >> > HttpServerDispatch that allows you to use your own custom executor for > >> > blocking tasks (which would allow you to tune the default worker task > >> pool > >> > very small). If you are using servlet APIs though that uses the standard > >> > pools we provide. > >> > > >> > Is there a particular reason you want to kill idle threads? Threads are > >> cheap > >> > unless you are storing massive amounts of thread local data. > >> > > >> > -- > >> > Jason T. Greene > >> > WildFly Lead / JBoss EAP Platform Architect > >> > JBoss, a division of Red Hat > >> > > >> > > >> > > >> > _______________________________________________ > >> > undertow-dev mailing list > >> > undertow-dev at lists.jboss.org > >> > https://lists.jboss.org/mailman/listinfo/undertow-dev > >> > > > > > From sdouglas at redhat.com Sat Oct 17 09:03:36 2015 From: sdouglas at redhat.com (Stuart Douglas) Date: Sat, 17 Oct 2015 09:03:36 -0400 (EDT) Subject: [undertow-dev] webjars usage In-Reply-To: References: Message-ID: <645741511.32987160.1445087016326.JavaMail.zimbra@redhat.com> Can you link to your code? Stuart ----- Original Message ----- > From: "Bulut Aras" > To: undertow-dev at lists.jboss.org > Sent: Saturday, 17 October, 2015 12:54:37 PM > Subject: [undertow-dev] webjars usage > > Hi, > I don't know if this is the right place but I have problems setting up > webjars in a maven project with undertow. I added dependencies to the > pom.xml. But can't figure out how to set up Resource/File handler. > > Thanks in advance. > _______________________________________________ > undertow-dev mailing list > undertow-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/undertow-dev > From greg.hellings at gmail.com Sat Oct 17 10:34:47 2015 From: greg.hellings at gmail.com (Greg Hellings) Date: Sat, 17 Oct 2015 09:34:47 -0500 Subject: [undertow-dev] HttpServerExchange In-Reply-To: References: Message-ID: Ping. --Greg On Oct 8, 2015 11:41 AM, "Greg Hellings" wrote: > I'm trying to mock out the HttpServerExchange object in my tests, but > I apparently cannot do so because the class is declared final. Why is > it final? Does that give Undertow anything beneficial? > > If there's good reason to not remove the final, I can just wrap the > object in a proxy class that's not final, but I'd rather not do that > just to get around limitations in mocking. Another alternative would > be for me to skip unit tests on the handler methods and leverage > integration tests.But there are sometimes bits of logic in the handler > that I want to Unit Test directly. > > Any help would be appreciated. > > --Greg > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151017/7de12c0f/attachment.html From jason.greene at redhat.com Sat Oct 17 13:42:58 2015 From: jason.greene at redhat.com (Jason T. Greene) Date: Sat, 17 Oct 2015 13:42:58 -0400 (EDT) Subject: [undertow-dev] HttpServerExchange In-Reply-To: References: Message-ID: <9458D352-1048-4AE4-832E-7AAE335D145E@redhat.com> Sorry for the delay. A number of us were traveling when you sent it. The reason the class is final is just following the common practice of explicitly disallowing inheritance unless the class is explicitly designed for it. The rationale behind the practice is that a class that allows inheritance essentially has a fixed implementation that can not evolve without potentially breaking compatibility. Additionally if the class has concurrency behavior, inheritance that is not designed around an explicit synchronization contract can lead to all kinds of bugs. If you do want to use mock testing, there are frameworks like easymock which can generate proxies for you, and your test code stays quite clean. > On Oct 17, 2015, at 9:40 AM, Greg Hellings wrote: > > Ping. > > --Greg > >> On Oct 8, 2015 11:41 AM, "Greg Hellings" wrote: >> I'm trying to mock out the HttpServerExchange object in my tests, but >> I apparently cannot do so because the class is declared final. Why is >> it final? Does that give Undertow anything beneficial? >> >> If there's good reason to not remove the final, I can just wrap the >> object in a proxy class that's not final, but I'd rather not do that >> just to get around limitations in mocking. Another alternative would >> be for me to skip unit tests on the handler methods and leverage >> integration tests.But there are sometimes bits of logic in the handler >> that I want to Unit Test directly. >> >> Any help would be appreciated. >> >> --Greg > _______________________________________________ > 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/20151017/2c71a466/attachment-0001.html From jason.greene at redhat.com Sat Oct 17 13:52:47 2015 From: jason.greene at redhat.com (Jason T. Greene) Date: Sat, 17 Oct 2015 13:52:47 -0400 (EDT) Subject: [undertow-dev] HttpServerExchange In-Reply-To: <9458D352-1048-4AE4-832E-7AAE335D145E@redhat.com> References: <9458D352-1048-4AE4-832E-7AAE335D145E@redhat.com> Message-ID: Sorry I meant powermock. > On Oct 17, 2015, at 12:43 PM, Jason T. Greene wrote: > > Sorry for the delay. A number of us were traveling when you sent it. > > The reason the class is final is just following the common practice of explicitly disallowing inheritance unless the class is explicitly designed for it. The rationale behind the practice is that a class that allows inheritance essentially has a fixed implementation that can not evolve without potentially breaking compatibility. Additionally if the class has concurrency behavior, inheritance that is not designed around an explicit synchronization contract can lead to all kinds of bugs. > > If you do want to use mock testing, there are frameworks like easymock which can generate proxies for you, and your test code stays quite clean. > >> On Oct 17, 2015, at 9:40 AM, Greg Hellings wrote: >> >> Ping. >> >> --Greg >> >>> On Oct 8, 2015 11:41 AM, "Greg Hellings" wrote: >>> I'm trying to mock out the HttpServerExchange object in my tests, but >>> I apparently cannot do so because the class is declared final. Why is >>> it final? Does that give Undertow anything beneficial? >>> >>> If there's good reason to not remove the final, I can just wrap the >>> object in a proxy class that's not final, but I'd rather not do that >>> just to get around limitations in mocking. Another alternative would >>> be for me to skip unit tests on the handler methods and leverage >>> integration tests.But there are sometimes bits of logic in the handler >>> that I want to Unit Test directly. >>> >>> Any help would be appreciated. >>> >>> --Greg >> _______________________________________________ >> undertow-dev mailing list >> undertow-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/undertow-dev > _______________________________________________ > 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/20151017/2fb2d045/attachment.html From melghaouat at gmail.com Mon Oct 19 11:22:58 2015 From: melghaouat at gmail.com (Mohammed ElGhaouat) Date: Mon, 19 Oct 2015 17:22:58 +0200 Subject: [undertow-dev] Resizing undertow thread pool size dynamically In-Reply-To: <1485621145.32986999.1445086861898.JavaMail.zimbra@redhat.com> References: <779237744.346643.1439369723927.JavaMail.zimbra@redhat.com> <1485621145.32986999.1445086861898.JavaMail.zimbra@redhat.com> Message-ID: Is this valid for Wildfly? (I am using 8.2.1) >From the previous replies, I understood that the ServletExtension could be used for embedded Undertow not for Wildfly. Anyway, I gave it a try, but still having Wildfly using task-max-threads and io-threads parameters from (subsystem=io/worker=default/). To test this solution, I created a simple wepapp with one simple Servlet and my ServletExtension.handleDeployment is executed by the Wildfly. Thanks On Sat, Oct 17, 2015 at 3:01 PM, Stuart Douglas wrote: > Like I said, you can use any thread pool you want if you modify it using a > ServletExtension. > > Code looks like: > > > public class MyExtension implements ServletExtension { > > @Override > public void handleDeployment(DeploymentInfo deploymentInfo, > ServletContext servletContext) { > Executor myThreadPool = {my thread pool}; > deploymentInfo.setExecutor(myThreadPool); > } > } > > Then add a META-INF/services entry for the extension. > > Stuart > > ----- Original Message ----- > > From: "Mohammed ElGhaouat" > > To: "Stuart Douglas" > > Cc: "Jason Greene" , > undertow-dev at lists.jboss.org > > Sent: Wednesday, 14 October, 2015 12:22:20 PM > > Subject: Re: [undertow-dev] Resizing undertow thread pool size > dynamically > > > > Hello, > > > > I would like to share with you some more details about our situation. We > > are using some big machines that are shared by many software(many Wildfly > > instances, Databases, ERPs ..) If i don't set pools sizes i end up with > big > > pools as the default size is dependent on the number of CPU cores and out > > system administrator is complaining about the OS spending time checking > if > > the threads have something to do and this impact the other softwares > > installed on the same machine. If I set a small pool size which could > > sufficient in the 90% of time, i am afraid that Wildfly couldn't handle > > the 10% of time when the applications are used by a large number of user. > > > > Is there any workaround or are you planning to let the user to set a > > specific ThreadPoolExecutor ? so we can evict idle threads > > > > > > Thanks, > > > > Mohammed. > > > > > > On Wed, Aug 12, 2015 at 11:03 AM, Mohammed ElGhaouat < > melghaouat at gmail.com> > > wrote: > > > > > I am using Wildfly. > > > > > > Thanks, > > > > > > Mohammed. > > > > > > On Wed, Aug 12, 2015 at 10:55 AM, Stuart Douglas > > > wrote: > > > > > >> Are you using Wildfly or embedded Undertow? > > >> > > >> If it is the later you can just use > > >> io.undertow.servlet.api.DeploymentInfo#setExecutor to use whatever > > >> executor > > >> implementation you want. > > >> > > >> The reason why most executors don't reduce the number is because > there is > > >> generally very little point, a parked thread is generally very cheap, > > >> while > > >> creating new threads is relatively expensive. > > >> > > >> Stuart > > >> > > >> ----- Original Message ----- > > >> > From: "Mohammed ElGhaouat" > > >> > To: "Jason Greene" > > >> > Cc: undertow-dev at lists.jboss.org > > >> > Sent: Wednesday, 12 August, 2015 6:19:11 PM > > >> > Subject: Re: [undertow-dev] Resizing undertow thread pool size > > >> dynamically > > >> > > > >> > We are using the servlet API and I am referring to worker pool. > Simply > > >> we > > >> > don't want keeping bunch of idle threads in the JVM consuming some > > >> resources > > >> > without doing any thing useful. > > >> > > > >> > So with the bounded queue executor, when the value of the > > >> task-max-threads > > >> > parameter is reached, the number of threads in the worker pool > couldn't > > >> be > > >> > decreased ? > > >> > > > >> > Thank you. > > >> > > > >> > > > >> > Mohammed. > > >> > > > >> > On Tue, Aug 11, 2015 at 9:50 PM, Jason Greene < > jason.greene at redhat.com > > >> > > > >> > wrote: > > >> > > > >> > > > >> > > > >> > > On Aug 11, 2015, at 4:42 AM, Mohammed ElGhaouat < > > >> melghaouat at gmail.com > > > >> > > wrote: > > >> > > > > >> > > > > >> > > Hi, > > >> > > > > >> > > I would like to know if there is a way to make undertow reducing > the > > >> size > > >> > > of the thread pool when the server is less loaded. Is there any > > >> > > parameter(or other way) that make an idle thread die after some > > >> inactivity > > >> > > time ? > > >> > > > >> > > > >> > Are you referring to the worker pool or the I/O pool? The I/O pool > is > > >> special > > >> > and is fixed. The worker pool currently uses a JDK > ThreadPoolExecutor > > >> with > > >> > an unbounded queue which is a behavior pattern typically desired > for web > > >> > servers. That?s not pluggable at the moment, but it could be > possible. > > >> > > > >> > If you are using the HttpHandler APIs, there is a method on > > >> > HttpServerDispatch that allows you to use your own custom executor > for > > >> > blocking tasks (which would allow you to tune the default worker > task > > >> pool > > >> > very small). If you are using servlet APIs though that uses the > standard > > >> > pools we provide. > > >> > > > >> > Is there a particular reason you want to kill idle threads? Threads > are > > >> cheap > > >> > unless you are storing massive amounts of thread local data. > > >> > > > >> > -- > > >> > Jason T. Greene > > >> > WildFly Lead / JBoss EAP Platform Architect > > >> > JBoss, a division of Red Hat > > >> > > > >> > > > >> > > > >> > _______________________________________________ > > >> > 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/20151019/9b43b5d1/attachment.html From gregcsco at gmail.com Mon Oct 19 11:41:14 2015 From: gregcsco at gmail.com (Greg) Date: Mon, 19 Oct 2015 09:41:14 -0600 Subject: [undertow-dev] corrupted messages? In-Reply-To: <300683561.32971583.1445072041963.JavaMail.zimbra@redhat.com> References: <300683561.32971583.1445072041963.JavaMail.zimbra@redhat.com> Message-ID: <15080c2fd90.2767.04e88ff03bf9c03035143a2e55c593c1@gmail.com> My mistake. We're seeing this with the 1.1.x builds (Wildfly 8). Moving to 1.2.x or later and Wildfly 9 has resolved the issue. Thanks for everyone's help. On October 17, 2015 2:54:03 AM Stuart Douglas wrote: > I have not been able to reproduce this. What OS are you using? Have you > been able to reproduce it on different machines? > > Stuart > > ----- Original Message ----- >> From: "Greg Shrack" >> To: undertow-dev at lists.jboss.org >> Sent: Friday, 9 October, 2015 4:05:43 PM >> Subject: [undertow-dev] corrupted messages? >> >> >> >> I'm seeing an inconsistent problem where some messages are corrupted. We're >> sending serialized objects over websockets, and are seeing some corrupted >> messages with larger messages and sometimes when sending more quickly. We've >> testing with a number of versions including undertow 1.1.8.Final, but was >> seeing the same issue with newer versions as well. Wireshark appears to show >> the corrupted data on the client side. >> >> >> >> >> I've included sample code. The server creates a handler at localhost:6025 and >> then listens for messages. When a message is received it checks the message >> against an expected pattern and prints out any bytes that don?t match. >> >> >> >> >> >> The client connects to the server and sends five 5000 byte messages one >> second apart. On my machine at least one of the 5 messages would come across >> with some corrupted data. I narrowed this down some - if the message is 2930 >> bytes, it appears to get through. At 2931, I start seeing some corruption. >> Using same test code with 1000 byte messages I was able to send 10000 >> messages with no sleep in between each send and all messages went through >> fine. >> >> >> >> >> >> Hopefully I'm missing something obvious. Thanks. >> >> >> >> >> ----- >> >> >> >> >> import io.undertow.Handlers; >> >> import io.undertow.Undertow; >> >> import io.undertow.websockets.WebSocketConnectionCallback; >> >> import io.undertow.websockets.core.AbstractReceiveListener; >> >> import io.undertow.websockets.core.BufferedBinaryMessage; >> >> import io.undertow.websockets.core.WebSocketChannel; >> >> import io.undertow.websockets.core.WebSockets; >> >> import io.undertow.websockets.spi.WebSocketHttpExchange; >> >> import org.xnio.Pooled; >> >> >> >> >> import java.io.IOException; >> >> import java.nio.ByteBuffer; >> >> import java.util.Arrays; >> >> >> >> >> public class WebsocketTestServer >> >> { >> >> public WebsocketTestServer() >> >> { >> >> Undertow server = Undertow.builder() >> >> .addHttpListener(6025, "localhost") >> >> .setHandler(Handlers.pathTemplate().add("test", Handlers.websocket(new >> TestHandler()))) >> >> .build(); >> >> >> >> >> server.start(); >> >> System.out.println("Server Started"); >> >> } >> >> >> >> >> private class TestHandler extends AbstractReceiveListener implements >> WebSocketConnectionCallback >> >> { >> >> @Override >> >> public void onConnect(WebSocketHttpExchange webSocketHttpExchange, >> WebSocketChannel webSocketChannel) >> >> { >> >> System.out.println("Client connected"); >> >> webSocketChannel.getReceiveSetter().set(this); >> >> webSocketChannel.resumeReceives(); >> >> } >> >> >> >> >> @Override >> >> protected void onFullBinaryMessage(WebSocketChannel channel, >> BufferedBinaryMessage message) throws IOException >> >> { >> >> try (Pooled pooled = message.getData()) >> >> { >> >> ByteBuffer[] buffers = pooled.getResource(); >> >> ByteBuffer bb = (buffers.length == 1) ? buffers[0] : >> WebSockets.mergeBuffers(buffers); >> >> if (bb.limit() > 0) >> >> { >> >> checkData(bb); >> >> } >> >> } >> >> } >> >> } >> >> >> >> >> // Checks data against expected pattern >> >> public static void checkData(ByteBuffer data) >> >> { >> >> long messageId = data.getLong(0); >> >> for (int i = Long.BYTES; i < data.limit(); i++) >> >> { >> >> byte expected = (byte) (i%256); >> >> byte actual = data.get(i); >> >> >> >> >> if (actual != expected) >> >> { >> >> System.err.println("**** Corrupted data for message " + messageId + " byte " >> + i + " expected " + expected + " but was " + actual); >> >> } >> >> } >> >> } >> >> >> >> >> >> >> >> public static void main(String[] args) throws InterruptedException >> >> { >> >> WebsocketTestServer server = new WebsocketTestServer(); >> >> >> >> >> while (true) >> >> { >> >> Thread.sleep(5000); >> >> } >> >> } >> >> >> >> } >> >> ---------- >> >> import javax.websocket.ClientEndpoint; >> import javax.websocket.ContainerProvider; >> import javax.websocket.OnOpen; >> import javax.websocket.Session; >> import javax.websocket.WebSocketContainer; >> import java.net.URI; >> import java.nio.ByteBuffer; >> >> @ClientEndpoint >> public class WebsocketTestClient >> { >> private Session session; >> >> public WebsocketTestClient() >> { >> try >> { >> WebSocketContainer container = ContainerProvider.getWebSocketContainer(); >> container.connectToServer(this, URI.create("ws://localhost:6025/test")); >> } >> catch (Exception e) >> { >> e.printStackTrace(); >> } >> } >> >> @OnOpen >> public void onOpen(Session session) >> { >> System.out.println("Session opened"); >> this.session = session; >> } >> >> public void sendData(long index) >> { >> try >> { >> session.getBasicRemote().sendBinary(createTestData(index)); >> } >> catch (Exception e) >> { >> e.printStackTrace(); >> } >> } >> >> public static final ByteBuffer createTestData(long messageId) >> { >> ByteBuffer buffer = ByteBuffer.allocate(5000); >> buffer.putLong(messageId); >> for(int i=Long.BYTES; i< buffer.limit(); i++) >> { >> buffer.put((byte) (i%256)); >> } >> buffer.flip(); >> >> return buffer; >> } >> >> public static void main(String[] args) throws InterruptedException >> { >> WebsocketTestClient client = new WebsocketTestClient(); >> Thread.sleep(1000); >> >> for(int i=0; i<5; i++) >> { >> System.out.println("Sending " + i); >> client.sendData(i); >> Thread.sleep(1000); >> } >> System.out.println("Done"); >> } >> } >> >> >> >> >> >> >> >> >> >> >> >> _______________________________________________ >> undertow-dev mailing list >> undertow-dev at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/undertow-dev From sdouglas at redhat.com Mon Oct 19 16:19:25 2015 From: sdouglas at redhat.com (Stuart Douglas) Date: Mon, 19 Oct 2015 16:19:25 -0400 (EDT) Subject: [undertow-dev] Resizing undertow thread pool size dynamically In-Reply-To: References: <779237744.346643.1439369723927.JavaMail.zimbra@redhat.com> <1485621145.32986999.1445086861898.JavaMail.zimbra@redhat.com> Message-ID: <660287892.33618073.1445285965479.JavaMail.zimbra@redhat.com> ----- Original Message ----- > From: "Mohammed ElGhaouat" > To: "Stuart Douglas" > Cc: "Jason Greene" , undertow-dev at lists.jboss.org > Sent: Tuesday, 20 October, 2015 2:22:58 AM > Subject: Re: [undertow-dev] Resizing undertow thread pool size dynamically > > Is this valid for Wildfly? (I am using 8.2.1) Yes, this is valid for all Servlet deployments, in both Wildfly and embedded Undertow. Wildfly will still create its worker thread pool, but it should not get used for this deployment. Stuart > > From the previous replies, I understood that the ServletExtension could be > used for embedded Undertow not for Wildfly. Anyway, I gave it a try, but > still having Wildfly using task-max-threads and io-threads parameters from > (subsystem=io/worker=default/). > > To test this solution, I created a simple wepapp with one simple Servlet > and my ServletExtension.handleDeployment is executed by the Wildfly. > > > Thanks > > On Sat, Oct 17, 2015 at 3:01 PM, Stuart Douglas wrote: > > > Like I said, you can use any thread pool you want if you modify it using a > > ServletExtension. > > > > Code looks like: > > > > > > public class MyExtension implements ServletExtension { > > > > @Override > > public void handleDeployment(DeploymentInfo deploymentInfo, > > ServletContext servletContext) { > > Executor myThreadPool = {my thread pool}; > > deploymentInfo.setExecutor(myThreadPool); > > } > > } > > > > Then add a META-INF/services entry for the extension. > > > > Stuart > > > > ----- Original Message ----- > > > From: "Mohammed ElGhaouat" > > > To: "Stuart Douglas" > > > Cc: "Jason Greene" , > > undertow-dev at lists.jboss.org > > > Sent: Wednesday, 14 October, 2015 12:22:20 PM > > > Subject: Re: [undertow-dev] Resizing undertow thread pool size > > dynamically > > > > > > Hello, > > > > > > I would like to share with you some more details about our situation. We > > > are using some big machines that are shared by many software(many Wildfly > > > instances, Databases, ERPs ..) If i don't set pools sizes i end up with > > big > > > pools as the default size is dependent on the number of CPU cores and out > > > system administrator is complaining about the OS spending time checking > > if > > > the threads have something to do and this impact the other softwares > > > installed on the same machine. If I set a small pool size which could > > > sufficient in the 90% of time, i am afraid that Wildfly couldn't handle > > > the 10% of time when the applications are used by a large number of user. > > > > > > Is there any workaround or are you planning to let the user to set a > > > specific ThreadPoolExecutor ? so we can evict idle threads > > > > > > > > > Thanks, > > > > > > Mohammed. > > > > > > > > > On Wed, Aug 12, 2015 at 11:03 AM, Mohammed ElGhaouat < > > melghaouat at gmail.com> > > > wrote: > > > > > > > I am using Wildfly. > > > > > > > > Thanks, > > > > > > > > Mohammed. > > > > > > > > On Wed, Aug 12, 2015 at 10:55 AM, Stuart Douglas > > > > wrote: > > > > > > > >> Are you using Wildfly or embedded Undertow? > > > >> > > > >> If it is the later you can just use > > > >> io.undertow.servlet.api.DeploymentInfo#setExecutor to use whatever > > > >> executor > > > >> implementation you want. > > > >> > > > >> The reason why most executors don't reduce the number is because > > there is > > > >> generally very little point, a parked thread is generally very cheap, > > > >> while > > > >> creating new threads is relatively expensive. > > > >> > > > >> Stuart > > > >> > > > >> ----- Original Message ----- > > > >> > From: "Mohammed ElGhaouat" > > > >> > To: "Jason Greene" > > > >> > Cc: undertow-dev at lists.jboss.org > > > >> > Sent: Wednesday, 12 August, 2015 6:19:11 PM > > > >> > Subject: Re: [undertow-dev] Resizing undertow thread pool size > > > >> dynamically > > > >> > > > > >> > We are using the servlet API and I am referring to worker pool. > > Simply > > > >> we > > > >> > don't want keeping bunch of idle threads in the JVM consuming some > > > >> resources > > > >> > without doing any thing useful. > > > >> > > > > >> > So with the bounded queue executor, when the value of the > > > >> task-max-threads > > > >> > parameter is reached, the number of threads in the worker pool > > couldn't > > > >> be > > > >> > decreased ? > > > >> > > > > >> > Thank you. > > > >> > > > > >> > > > > >> > Mohammed. > > > >> > > > > >> > On Tue, Aug 11, 2015 at 9:50 PM, Jason Greene < > > jason.greene at redhat.com > > > >> > > > > >> > wrote: > > > >> > > > > >> > > > > >> > > > > >> > > On Aug 11, 2015, at 4:42 AM, Mohammed ElGhaouat < > > > >> melghaouat at gmail.com > > > > >> > > wrote: > > > >> > > > > > >> > > > > > >> > > Hi, > > > >> > > > > > >> > > I would like to know if there is a way to make undertow reducing > > the > > > >> size > > > >> > > of the thread pool when the server is less loaded. Is there any > > > >> > > parameter(or other way) that make an idle thread die after some > > > >> inactivity > > > >> > > time ? > > > >> > > > > >> > > > > >> > Are you referring to the worker pool or the I/O pool? The I/O pool > > is > > > >> special > > > >> > and is fixed. The worker pool currently uses a JDK > > ThreadPoolExecutor > > > >> with > > > >> > an unbounded queue which is a behavior pattern typically desired > > for web > > > >> > servers. That?s not pluggable at the moment, but it could be > > possible. > > > >> > > > > >> > If you are using the HttpHandler APIs, there is a method on > > > >> > HttpServerDispatch that allows you to use your own custom executor > > for > > > >> > blocking tasks (which would allow you to tune the default worker > > task > > > >> pool > > > >> > very small). If you are using servlet APIs though that uses the > > standard > > > >> > pools we provide. > > > >> > > > > >> > Is there a particular reason you want to kill idle threads? Threads > > are > > > >> cheap > > > >> > unless you are storing massive amounts of thread local data. > > > >> > > > > >> > -- > > > >> > Jason T. Greene > > > >> > WildFly Lead / JBoss EAP Platform Architect > > > >> > JBoss, a division of Red Hat > > > >> > > > > >> > > > > >> > > > > >> > _______________________________________________ > > > >> > undertow-dev mailing list > > > >> > undertow-dev at lists.jboss.org > > > >> > https://lists.jboss.org/mailman/listinfo/undertow-dev > > > >> > > > > > > > > > > > > > > From dhamudeva at gmail.com Sun Oct 18 07:04:24 2015 From: dhamudeva at gmail.com (Dhamodharan Devarajan) Date: Sun, 18 Oct 2015 11:04:24 +0000 Subject: [undertow-dev] IllegalArgumentException - 'No servlet context to dispatch to' error in undertow for async servlet Message-ID: Hello, I am getting the below error when undertow tries to dispatch the httpresponse. java.lang.IllegalArgumentException: UT010046: No servlet context at to dispatch to at io.undertow.servlet.spec.AsyncContextImpl.dispatch(AsyncContextImpl.java:173) [undertow-servlet-1.1.0.Final.jar!/:1.1.0.Final] at org.eclipse.jetty.continuation.Servlet3Continuation.resume(Servlet3Continuation.java:152) ~[jetty-continuation.jar:8.1.3.v20120416] at com.xyz.xyzapp.apihandler.util.AsyncJobWaitingAPIHandler$MultiJobCompletionContext.onListenerCompletion(AsyncJobWaitingAPIHandler.java:460) ~[xyzapp-apihandler.jar:1.4.1-2015.10.dev] at com.xyz.xyzapp.apihandler.util.AsyncJobWaitingAPIHandler$MultiJobCompletionListener.onCompletion(AsyncJobWaitingAPIHandler.java:492) ~[xyzapp-apihandler.jar:1.4.1-2015.10.dev] at com.xyz.xyzapp.job.JobEngine$4.onEvent(JobEngine.java:274) ~[xyzapp-job.jar:1.4.1-2015.10.dev] at com.xyz.xyzapp.job.JobEngine$4.onEvent(JobEngine.java:269) ~[xyzapp-job.jar:1.4.1-2015.10.dev] at com.xyz.xyzapp.core.event.multicast.LocalMulticastEventManager$1.run(LocalMulticastEventManager.java:134) ~[xyzapp-core.jar:1.4.1-2015.10.dev] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53) ~[spring-context.jar:3.2.9.RELEASE] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_51] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_51] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_51] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_51] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_51] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_51] I am using Jetty.Continuation (8.1.3) to suspend the HTTPrequest until it has the response. I have spring (3.2.9) application that is deployed in wildfly (8.2.0.Final). Spring servlet is configured via web-fragment.xml to indicate that servlet is asynchronous apis com.xyz.xyzapp.server.common.spring.ClassloaderOverridingDispatcherServlet 1 true When one of the job (job is internal framework) completes, it need to respond back to clients (whoever is listening) that job is completed. During this workflow, I am getting the above error. I made sure the wildfly is up and running, clients are actually waiting for response. This was working with Jboss 6.1.0.Final/Tomcat. What could be the problem? Any configuration I need to add in standalone-full.xml for undertow? It appears that undertow closed the HTTPrequest, not sure. Regards, Dhamodharan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151018/7de13d34/attachment.html From sdouglas at redhat.com Mon Oct 19 16:52:14 2015 From: sdouglas at redhat.com (Stuart Douglas) Date: Mon, 19 Oct 2015 16:52:14 -0400 (EDT) Subject: [undertow-dev] IllegalArgumentException - 'No servlet context to dispatch to' error in undertow for async servlet In-Reply-To: References: Message-ID: <1560283598.33626837.1445287934538.JavaMail.zimbra@redhat.com> Do you have a simple reproducer for this? Stuart ----- Original Message ----- > From: "Dhamodharan Devarajan" > To: undertow-dev at lists.jboss.org > Sent: Sunday, 18 October, 2015 10:04:24 PM > Subject: [undertow-dev] IllegalArgumentException - 'No servlet context to dispatch to' error in undertow for async > servlet > > Hello, > > I am getting the below error when undertow tries to dispatch the > httpresponse. > > java.lang.IllegalArgumentException: UT010046: No servlet context at to > dispatch to > at > io.undertow.servlet.spec.AsyncContextImpl.dispatch(AsyncContextImpl.java:173) > [undertow-servlet-1.1.0.Final.jar!/:1.1.0.Final] > at > org.eclipse.jetty.continuation.Servlet3Continuation.resume(Servlet3Continuation.java:152) > ~[jetty-continuation.jar:8.1.3.v20120416] > at > com.xyz.xyzapp.apihandler.util.AsyncJobWaitingAPIHandler$MultiJobCompletionContext.onListenerCompletion(AsyncJobWaitingAPIHandler.java:460) > ~[xyzapp-apihandler.jar:1.4.1-2015.10.dev] > at > com.xyz.xyzapp.apihandler.util.AsyncJobWaitingAPIHandler$MultiJobCompletionListener.onCompletion(AsyncJobWaitingAPIHandler.java:492) > ~[xyzapp-apihandler.jar:1.4.1-2015.10.dev] > at com.xyz.xyzapp.job.JobEngine$4.onEvent(JobEngine.java:274) > ~[xyzapp-job.jar:1.4.1-2015.10.dev] > at com.xyz.xyzapp.job.JobEngine$4.onEvent(JobEngine.java:269) > ~[xyzapp-job.jar:1.4.1-2015.10.dev] > at > com.xyz.xyzapp.core.event.multicast.LocalMulticastEventManager$1.run(LocalMulticastEventManager.java:134) > ~[xyzapp-core.jar:1.4.1-2015.10.dev] > at > org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53) > ~[spring-context.jar:3.2.9.RELEASE] > at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > [na:1.8.0_51] > at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_51] > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) > [na:1.8.0_51] > at > java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) > [na:1.8.0_51] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > [na:1.8.0_51] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > [na:1.8.0_51] > > I am using Jetty.Continuation (8.1.3) to suspend the HTTPrequest until it has > the response. I have spring (3.2.9) application that is deployed in wildfly > (8.2.0.Final). Spring servlet is configured via web-fragment.xml to indicate > that servlet is asynchronous > > > apis > com.xyz.xyzapp.server.common.spring.ClassloaderOverridingDispatcherServlet > 1 > true > > > When one of the job (job is internal framework) completes, it need to respond > back to clients (whoever is listening) > that job is completed. During this workflow, I am getting the above error. > > I made sure the wildfly is up and running, clients are actually waiting for > response. > > This was working with Jboss 6.1.0.Final/Tomcat. > > What could be the problem? Any configuration I need to add in > standalone-full.xml for undertow? It appears that undertow closed the > HTTPrequest, not sure. > > Regards, > Dhamodharan > > _______________________________________________ > undertow-dev mailing list > undertow-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/undertow-dev From leleuj at gmail.com Tue Oct 20 11:17:20 2015 From: leleuj at gmail.com (=?UTF-8?B?SsOpcsO0bWUgTEVMRVU=?=) Date: Tue, 20 Oct 2015 17:17:20 +0200 Subject: [undertow-dev] Upgrade of undertow-pac4j Message-ID: Hi, A few days ago, we released pac4j v1.8 which is now a full security engine supporting authentication (for UI and web services), but also authorization (see: https://github.com/pac4j/pac4j). It now provides guidelines on how to create a full security library based on it. There is currently a undertow-pac4j v1.0 which is based on pac4j v1.7 and supports authentication (only for UI). I'd like to upgrade this library in a new version 1.1 based on pac4j v1.8. It's mostly a smart copy/paste of the j2e-pac4j implementation and the upgrade really worths it! Although I could do this on my own, I'm looking for volunteers on this upgrade to make things happen faster and get feedbacks. Thanks. Best regards, J?r?me -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151020/5ab517d9/attachment.html