<div dir="ltr"><div id="yui_3_16_0_1_1444397807457_6087" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><p class="" id="yui_3_16_0_1_1444397807457_6086" style="font-size:13px;margin:0px;padding:0px"><span style="font-size:10.5pt">I&#39;m seeing an inconsistent problem where some messages are corrupted. We&#39;re sending serialized objects over websockets, and are seeing some corrupted messages with larger messages and sometimes when sending more quickly. </span><span style="font-size:14px">We&#39;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.</span></p><p class="" id="yui_3_16_0_1_1444397807457_6086" style="font-size:13px;margin:0px;padding:0px"><span style="font-size:14px"><br></span></p><p class="" id="yui_3_16_0_1_1444397807457_6086" style="margin:0px;padding:0px"><span style="font-size:14px">I&#39;ve included sample code. </span><span style="font-size:10.5pt">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.</span></p></div><div id="yui_3_16_0_1_1444397807457_6085" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;font-size:13px"><p class="" id="yui_3_16_0_1_1444397807457_6084" style="margin:0px;padding:0px"><span style="font-size:10.5pt"> </span></p></div><div id="yui_3_16_0_1_1444397807457_5777" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;font-size:13px"><p class="" id="yui_3_16_0_1_1444397807457_5776" style="margin:0px;padding:0px"><span id="yui_3_16_0_1_1444397807457_5775" style="font-size:10.5pt">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. </span><span style="font-size:14px">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.  </span></p></div><div id="yui_3_16_0_1_1444397807457_5919" style=""><p class="" id="yui_3_16_0_1_1444397807457_5918" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;font-size:13px;margin:0px;padding:0px"><br></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;margin:0px;padding:0px"><span style="font-size:14px">Hopefully I&#39;m missing something obvious. Thanks.</span></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;margin:0px;padding:0px"><span style="font-size:14px"><br></span></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;margin:0px;padding:0px"><span style="font-size:14px">-----</span></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;margin:0px;padding:0px"><span style="font-size:14px"><br></span></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import io.undertow.Handlers;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import io.undertow.Undertow;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import io.undertow.websockets.WebSocketConnectionCallback;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import io.undertow.websockets.core.AbstractReceiveListener;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import io.undertow.websockets.core.BufferedBinaryMessage;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import io.undertow.websockets.core.WebSocketChannel;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import io.undertow.websockets.core.WebSockets;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import io.undertow.websockets.spi.WebSocketHttpExchange;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import org.xnio.Pooled;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import java.io.IOException;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import java.nio.ByteBuffer;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">import java.util.Arrays;</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">public class WebsocketTestServer</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">{</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  public WebsocketTestServer()</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    Undertow server = Undertow.builder()</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        .addHttpListener(6025, &quot;localhost&quot;)</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        .setHandler(Handlers.pathTemplate().add(&quot;test&quot;, Handlers.websocket(new TestHandler())))</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        .build();</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    server.start();</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    System.out.println(&quot;Server Started&quot;);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  private class TestHandler extends AbstractReceiveListener implements WebSocketConnectionCallback</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    @Override</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    public void onConnect(WebSocketHttpExchange webSocketHttpExchange, WebSocketChannel webSocketChannel)</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      System.out.println(&quot;Client connected&quot;);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      webSocketChannel.getReceiveSetter().set(this);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      webSocketChannel.resumeReceives();</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    @Override</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    protected void onFullBinaryMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      try (Pooled&lt;ByteBuffer[]&gt; pooled = message.getData())</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        ByteBuffer[] buffers = pooled.getResource();</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        ByteBuffer bb = (buffers.length == 1) ? buffers[0] : WebSockets.mergeBuffers(buffers);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        if (bb.limit() &gt; 0)</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">          checkData(bb);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  // Checks data against expected pattern</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  public static void checkData(ByteBuffer data)</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    long messageId = data.getLong(0);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    for (int i = Long.BYTES; i &lt; data.limit(); i++)</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      byte expected = (byte) (i%256);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      byte actual = data.get(i);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      if (actual != expected)</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">        System.err.println(&quot;**** Corrupted data for message &quot; + messageId + &quot; byte &quot; + i + &quot; expected &quot; + expected + &quot; but was &quot; + actual);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  public static void main(String[] args) throws InterruptedException</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    WebsocketTestServer server = new WebsocketTestServer();</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px"><br></span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    while (true)</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    {</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">      Thread.sleep(5000);</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">    }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">  }</span></font></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"></p><p class="" id="yui_3_16_0_1_1444397807457_5918" style="margin:0px;padding:0px"><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><span style="font-size:14px">}</span></font></p><div style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><br></div><div style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif">----------</div><div style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><br></div><div style=""><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">import javax.websocket.ClientEndpoint;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">import javax.websocket.ContainerProvider;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">import javax.websocket.OnOpen;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">import javax.websocket.Session;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">import javax.websocket.WebSocketContainer;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">import java.net.URI;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">import java.nio.ByteBuffer;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">@ClientEndpoint</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">public class WebsocketTestClient</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">{</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  private Session session;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  public WebsocketTestClient()</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    try</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      WebSocketContainer container = ContainerProvider.getWebSocketContainer();</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      container.connectToServer(this, URI.create(&quot;ws://localhost:6025/test&quot;));</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    catch (Exception e)</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      e.printStackTrace();</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  @OnOpen</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  public void onOpen(Session session)</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    System.out.println(&quot;Session opened&quot;);</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    this.session = session;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  public void sendData(long index)</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    try</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      session.getBasicRemote().sendBinary(createTestData(index));</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    catch (Exception e)</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      e.printStackTrace();</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  public static final ByteBuffer createTestData(long messageId)</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    ByteBuffer buffer = ByteBuffer.allocate(5000);</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    buffer.putLong(messageId);</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    for(int i=Long.BYTES; i&lt; buffer.limit(); i++)</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      buffer.put((byte) (i%256));</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    buffer.flip();</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    return buffer;</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  public static void main(String[] args) throws InterruptedException</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    WebsocketTestClient client = new WebsocketTestClient();</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    Thread.sleep(1000);</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif"><br></font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    for(int i=0; i&lt;5; i++)</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    {</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      System.out.println(&quot;Sending &quot; + i);</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      client.sendData(i);</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">      Thread.sleep(1000);</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">    System.out.println(&quot;Done&quot;);</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">  }</font></div><div style=""><font color="#000000" face="Helvetica Neue, Segoe UI, Helvetica, Arial, Lucida Grande, sans-serif">}</font></div><div style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif"><br></div></div></div><div id="yui_3_16_0_1_1444397807457_5922" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;font-size:13px"><p class="" id="yui_3_16_0_1_1444397807457_5921" style="margin:0px;padding:0px"><br></p></div><div id="yui_3_16_0_1_1444397807457_5926" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;font-size:13px"><p class="" id="yui_3_16_0_1_1444397807457_5925" style="margin:0px;padding:0px"><span style="font-size:10.5pt"> </span></p></div><div id="yui_3_16_0_1_1444397807457_5381" style="color:rgb(0,0,0);font-family:&#39;Helvetica Neue&#39;,&#39;Segoe UI&#39;,Helvetica,Arial,&#39;Lucida Grande&#39;,sans-serif;font-size:13px"><p class="" id="yui_3_16_0_1_1444397807457_5380" style="margin:0px;padding:0px"><br></p></div></div>