diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java
index 1bc7366ee54..dd6431d0c95 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java
@@ -73,6 +73,12 @@ public interface LogicalConnection extends OutgoingFrames, SuspendToken
*/
InetSocketAddress getLocalAddress();
+ /**
+ * Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)
+ * @return the idle timeout in milliseconds
+ */
+ long getMaxIdleTimeout();
+
/**
* The policy that the connection is running under.
* @return the policy for the connection
@@ -109,6 +115,14 @@ public interface LogicalConnection extends OutgoingFrames, SuspendToken
*/
boolean isReading();
+ /**
+ * Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)
+ *
+ * @param ms
+ * the number of milliseconds of idle timeout
+ */
+ void setMaxIdleTimeout(long ms);
+
/**
* Set where the connection should send the incoming frames to.
*
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java
index 0d648c6adaf..cb80189b5fe 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java
@@ -59,7 +59,6 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
private ExtensionFactory extensionFactory;
private long maximumMessageSize;
private String protocolVersion;
- private long timeout;
private Map parameterMap = new HashMap<>();
private WebSocketRemoteEndpoint remote;
private IncomingFrames incomingHandler;
@@ -165,12 +164,12 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
}
/**
- * The idle timeout in seconds
+ * The idle timeout in milliseconds
*/
@Override
public long getIdleTimeout()
{
- return timeout;
+ return connection.getMaxIdleTimeout();
}
@ManagedAttribute(readonly = true)
@@ -320,12 +319,12 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
}
/**
- * Set the timeout in seconds
+ * Set the timeout in milliseconds
*/
@Override
- public void setIdleTimeout(long seconds)
+ public void setIdleTimeout(long ms)
{
- this.timeout = seconds;
+ connection.setMaxIdleTimeout(ms);
}
@Override
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxChannel.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxChannel.java
index 3e56bbd56fc..b8bd82508fb 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxChannel.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxChannel.java
@@ -111,6 +111,13 @@ public class MuxChannel implements LogicalConnection, IncomingFrames, SuspendTok
return null;
}
+ @Override
+ public long getMaxIdleTimeout()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
@Override
public WebSocketPolicy getPolicy()
{
@@ -205,6 +212,13 @@ public class MuxChannel implements LogicalConnection, IncomingFrames, SuspendTok
}
}
+ @Override
+ public void setMaxIdleTimeout(long ms)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
@Override
public void setNextIncomingFrames(IncomingFrames incoming)
{
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
index 289be61b17d..12091c194cb 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
@@ -347,6 +347,12 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
return ioState;
}
+ @Override
+ public long getMaxIdleTimeout()
+ {
+ return getEndPoint().getIdleTimeout();
+ }
+
public Parser getParser()
{
return parser;
@@ -568,6 +574,12 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
super.setInputBufferSize(inputBufferSize);
}
+ @Override
+ public void setMaxIdleTimeout(long ms)
+ {
+ getEndPoint().setIdleTimeout(ms);
+ }
+
@Override
public void setSession(WebSocketSession session)
{
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java
index 7099af3ac4c..5387af30d0b 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java
@@ -91,6 +91,13 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
return null;
}
+ @Override
+ public long getMaxIdleTimeout()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
@Override
public WebSocketPolicy getPolicy()
{
@@ -148,6 +155,13 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
{
}
+ @Override
+ public void setMaxIdleTimeout(long ms)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
@Override
public void setNextIncomingFrames(IncomingFrames incoming)
{