title: Notify the user about the end of the session in JSF 2.3
body: <p>JavaEE, JSF-2.3, Websocket, WebApplication, WildFly.<br/>
  For each user, a session is created, within which it operates, authorization, authentication, and so on. After 15 minutes of inactivity, the session is automatically destroyed, thanks to the settings of <strong>web.xml</strong> -</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;session-config&gt;
    &lt;session-timeout&gt;15&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  </code></pre>
  
  
  
  <p>In JSF-2.3 available WebSocket, so I decided to do so <strong>ExitBean.java</strong> -</p>
  
  <pre class="lang-java prettyprint-override"><code>@Inject
  @Push(channel = "exit")
  PushContext push;
  
  @PreDestroy
  public void sessionTimeOut() {
      push.send("exitEvent");
  }
  </code></pre>
  
  <p>On the page, respectively, <strong>exit.xhtml</strong> -</p>
  
  <pre class="lang-xhtml prettyprint-override"><code>&lt;h:form &gt;
    &lt;f:websocket channel="exit" scope="session"&gt;
      &lt;f:ajax event="exitEvent" onevent="PF('dlg1').show()"/&gt;
    &lt;/f:websocket&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>At the end of the session, judging by the logs, the <code>sessionTimeOut()</code> method works, it's still <code>@PreDestroy</code>, but there is no response on the page.<br/>
  For the test, I placed a button on the <strong>exit.xhtml</strong> page, by clicking on which the <code>sessionTimeOut()</code> method is called. When this button is clicked, event - "exitEvent", executes as expected, invoking the PrimeFaces script <code>PF('dlg1').show()</code>, which displays a dialog box.<br/>
  I suspect that websockets are killed even earlier than the <code>@Predestroy</code> method is called.<br/>
  There is another option with the websocket, it looks like this:</p>
  
  <pre class="lang-xhtml prettyprint-override"><code>&lt;h:form &gt;
    &lt;f:websocket channel="exit" scope="session" onclose="PF('dlg1').show()"/&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>But it works only when the page loads and again no reaction to the end of the session.<br/>
  Two questions:</p>
  
  <ol>
  <li>How to handle the end of a session using websockets?</li>
  <li>In extreme cases, offer an alternative.</li>
  </ol>