3

I'm using Omnifaces websocket. Session is never timeout. I tried with jsf websocket. There's the same result. When I go to another page that doesn't use websocket and stays at that page, session will expire normally. Here are example of my codes xhtml with javascript:

 <o:socket channel="message"   onmessage="onMessage" /> 

and function onMessage as

 function onMessage(message, channel, event) {
            var newBcMsgs = document.getElementById("topF\:newMsgs");
            if (!isEmpty(newBcMsgs)) {
                addClass(newBcMsgs, "active");
                addClass(newBcMsgs, "text-warning");
                sessionStorage.setItem(document.getElementById('usernameTop').innerHTML, "news");
            }
        }

In managedbean with ApplicationScoped(import omnifaces.cdi.Push, PushContext) :

  @Inject
    @Push(channel = "message")
    private PushContext pushMessage;

    public void sendMessage(final String msgs) {
        logger.debug("send a msgs now: {}", () -> msgs);
        pushMessage.send(msgs);
    }

I'm using Omnifaces 3.6 with Payara 5.201 Jakartee 8. So, what should I do or correct for allowing session expried if there're long idle times?

PeterL355
  • 75
  • 1
  • 9
  • If it fails with both implementations, it is most likely is not related to either but websockets in general. Tried setting an explicit timeout on the websoclet so it closes when no messages are sent? – Kukeltje May 26 '20 at 18:08
  • In jsf websocket or Omnifaces, I can't find a code to set websocket session timeout. – PeterL355 May 27 '20 at 10:33
  • These are set on the container level... The ones that do the real socket things – Kukeltje May 27 '20 at 12:08
  • By tagging it payara, you are implying e.g. it works with tomcat or wildfly... – Kukeltje May 28 '20 at 13:16
  • 1
    No, I didn't test with Tomcat or Wildfly yet. I updated because it will be easy for searching. Also I've checked the Payara full version at domain.xml. There's no parameter to set an idle timeout for websocket. – PeterL355 May 28 '20 at 13:48
  • With f:websocket, the session doesn't timeout. Tested with wildfly 25.0.1.Final – grigouille Jan 10 '23 at 16:16

0 Answers0