diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/ControlFrameBytes.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/ControlFrameBytes.java index 418a011b9f8..fe9fab4e889 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/ControlFrameBytes.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/ControlFrameBytes.java @@ -2,6 +2,7 @@ package org.eclipse.jetty.websocket.io; import java.nio.ByteBuffer; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.generator.Generator; import org.eclipse.jetty.websocket.protocol.OpCode; @@ -35,6 +36,7 @@ public class ControlFrameBytes extends FrameBytes { buffer = connection.getBufferPool().acquire(frame.getPayloadLength() + Generator.OVERHEAD,false); connection.getGenerator().generate(frame); + BufferUtil.flipToFlush(buffer,0); } return buffer; } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/DataFrameBytes.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/DataFrameBytes.java index 8aa0b1750f9..665417f16f4 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/DataFrameBytes.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/DataFrameBytes.java @@ -2,6 +2,7 @@ package org.eclipse.jetty.websocket.io; import java.nio.ByteBuffer; +import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.protocol.WebSocketFrame; @@ -48,6 +49,7 @@ public class DataFrameBytes extends FrameBytes } buffer = connection.getGenerator().generate(size,frame); + BufferUtil.flipToFlush(buffer,0); return buffer; } catch (Throwable x) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketAsyncConnection.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketAsyncConnection.java index 3a448d08d9f..bc26d68c913 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketAsyncConnection.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/io/WebSocketAsyncConnection.java @@ -101,8 +101,9 @@ public class WebSocketAsyncConnection extends AbstractAsyncConnection implements } catch (IOException e) { + LOG.warn(e); terminateConnection(StatusCode.PROTOCOL,e.getMessage()); - return 0; + return -1; } } @@ -214,10 +215,9 @@ public class WebSocketAsyncConnection extends AbstractAsyncConnection implements @Override public void onFillable() { - LOG.debug("onFillable"); setCurrentConnection(this); ByteBuffer buffer = bufferPool.acquire(policy.getBufferSize(),false); - BufferUtil.clearToFill(buffer); + BufferUtil.clear(buffer); try { read(buffer); @@ -264,6 +264,7 @@ public class WebSocketAsyncConnection extends AbstractAsyncConnection implements break; } + LOG.debug("Filled {} bytes - {}",filled,BufferUtil.toDetailString(buffer)); parser.parse(buffer); } } diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java index 81d4ced0fd9..00e4a851638 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java @@ -355,9 +355,16 @@ public class BlockheadClient implements Parser.Listener { LOG.debug("write(Frame->{})",frame); frame.setMask(clientmask); + // frame.setMask(new byte[] { 0x00, 0x00, 0x00, 0x00 }); ByteBuffer buf = generator.generate(frame); BufferUtil.flipToFlush(buf,0); - BufferUtil.writeTo(buf,out); + if (LOG.isDebugEnabled()) + { + LOG.debug("writing out: {}",BufferUtil.toDetailString(buf)); + } + byte arr[] = BufferUtil.toArray(buf); + out.write(arr,0,arr.length); + out.flush(); } public void writeRaw(ByteBuffer buf) throws IOException