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?

6
  • 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
    Commented May 26, 2020 at 18:08
  • In jsf websocket or Omnifaces, I can't find a code to set websocket session timeout.
    – PeterL355
    Commented May 27, 2020 at 10:33
  • These are set on the container level... The ones that do the real socket things
    – Kukeltje
    Commented May 27, 2020 at 12:08
  • By tagging it payara, you are implying e.g. it works with tomcat or wildfly...
    – Kukeltje
    Commented May 28, 2020 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
    Commented May 28, 2020 at 13:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.