diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java index 530c010b926..60c8c2ec909 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java @@ -18,6 +18,7 @@ package org.eclipse.jetty.websocket.client.io; +import java.io.EOFException; import java.io.IOException; import java.net.URI; import java.nio.ByteBuffer; @@ -128,6 +129,12 @@ public class UpgradeConnection extends AbstractConnection } } + private void failUpgrade(Throwable cause) + { + close(); + connectPromise.failed(cause); + } + private void notifyConnect(ClientUpgradeResponse response) { connectPromise.setResponse(response); @@ -142,6 +149,10 @@ public class UpgradeConnection extends AbstractConnection @Override public void onFillable() { + if (LOG.isDebugEnabled()) + { + LOG.debug("onFillable"); + } ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),false); BufferUtil.clear(buffer); boolean readMore = false; @@ -164,9 +175,31 @@ public class UpgradeConnection extends AbstractConnection public void onOpen() { super.onOpen(); - // TODO: handle timeout? getExecutor().execute(new SendUpgradeRequest()); } + + @Override + public void onClose() + { + if (LOG.isDebugEnabled()) + { + LOG.warn("Closed connection {}",this); + } + super.onClose(); + } + + @Override + protected boolean onReadTimeout() + { + if (LOG.isDebugEnabled()) + { + LOG.warn("Timeout on connection {}",this); + } + + failUpgrade(new IOException("Timeout while performing WebSocket Upgrade")); + + return super.onReadTimeout(); + } /** * Read / Parse the waiting read/fill buffer @@ -189,7 +222,8 @@ public class UpgradeConnection extends AbstractConnection } else if (filled < 0) { - LOG.debug("read - EOF Reached"); + LOG.warn("read - EOF Reached"); + failUpgrade(new EOFException("Reading WebSocket Upgrade response")); return false; } else diff --git a/jetty-websocket/websocket-client/src/test/resources/jetty-logging.properties b/jetty-websocket/websocket-client/src/test/resources/jetty-logging.properties index 9668b131052..a5afe1edb35 100644 --- a/jetty-websocket/websocket-client/src/test/resources/jetty-logging.properties +++ b/jetty-websocket/websocket-client/src/test/resources/jetty-logging.properties @@ -1,6 +1,7 @@ org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog org.eclipse.jetty.LEVEL=WARN # org.eclipse.jetty.LEVEL=DEBUG +# org.eclipse.jetty.io.LEVEL=DEBUG # org.eclipse.jetty.io.ChannelEndPoint.LEVEL=DEBUG # org.eclipse.jetty.io.SelectChannelEndPoint.LEVEL=DEBUG # org.eclipse.jetty.io.IdleTimeout.LEVEL=DEBUG