Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The support for Sesssion.setIdleTimeout(long ms) was added recently to support JSR-356 (javax.websocket) work we are currently doing.</p> <p>However, with 9.0.0.RC2 you can do the following to set idle timeout early, before the Session is created (this is being fixed, hopefully will make it into RC3)</p> <p><strong>Server Side option A: WebSocketServlet init-param</strong></p> <p>In your <code>WEB-INF/web.xml</code> for your websocket servlet, specify the following init-param</p> <pre class="lang-xml prettyprint-override"><code>&lt;init-param&gt; &lt;param-name&gt;maxIdleTime&lt;/param-name&gt; &lt;param-value&gt;10000&lt;/param-value&gt; &lt;/init-param&gt; </code></pre> <p><strong>Server Side option B: As policy change on WebSocketFactory</strong></p> <p>In your WebSocketServlet.configure(WebSocketServletFactory factory) call</p> <pre class="lang-java prettyprint-override"><code>@Override public void configure(WebSocketServletFactory factory) { factory.getPolicy().setIdleTimeout(10000); } </code></pre> <p><strong>Client Side option A: As WebSocketClient setting</strong></p> <pre class="lang-java prettyprint-override"><code>WebSocketClient client = new WebSocketClient(); client.getPolicy().setIdleTimeout(10000); client.start(); </code></pre> <p><strong>Annotated @WebSocket option</strong></p> <p>This will work for server or client websockets.</p> <p>Note: you cannot mix WebSocketListener and @WebSocket annotations together</p> <pre class="lang-java prettyprint-override"><code>import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; import org.eclipse.jetty.websocket.api.annotations.WebSocket; @WebSocket(maxIdleTime=10000) public class MySocket { @OnWebSocketClose public void onClose(int statusCode, String reason) { } @OnWebSocketConnect public void onConnect(Session sess) { } @OnWebSocketError public void onError(Throwable cause) { } @OnWebSocketMessage public void onText(String message) { } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload