8 Replies Latest reply on Nov 19, 2014 10:31 AM by davidj

    WebSocket connection closes after 65 seconds no matter what

    davidj

      Hi,

      I'm using JBoss EAP 6.3.  I've got a Websocket that works fine for about 65 seconds.  Then it stops working.  It's state is still "OPEN" but nothing can be sent to it.  The exception is: java.lang.IllegalStateException: JBWEB008529: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method

       

      It doesn't matter how much or little information I send to it.  I could open the connection, then do nothing for 65 seconds and it would close.  Or, I could open the connection and constantly send messages for 65 seconds and it would work fine then close.  I'm not explicitly setting any timeout.  But as stated early, the problem cannot be related to "idle" (because it doesn't matter how little or much I send).

       

      I've tried on both Firefox and Chrome.

       

      The code is very simple, all I do is: session.getBasicRemote().sendText(message);  and it works fine about about 65 seconds, then booom!.

       

      Any ideas?

       

      Thanks,

       

      David Jensen

        • 1. Re: WebSocket connection closes after 65 seconds no matter what
          davidj

          I've been researching this all day without success, but I did come across something that might be a clue.

          65 seconds is a strange timeout value. I think the real timeout is probably 60 seconds and it just takes an extra 5 seconds for the Thread to stop.  So I debugged and examined the Web-socket Session object and found a value of 6000000000 for the "keepAliveTime" (under the executorService for remoteEndpointAsync/Basic).  See screenshot below:

           

          websocketThreadKeepAlive.JPG

          I tried changing that value in the debugger but it didn't make a difference, but that gave me the idea to search source-code in Tomcat/JBoss and found this:

           

          public static final String EXECUTOR_KEEPALIVETIME_SECONDS_INIT_PARAM = "org.apache.tomcat.websocket.executorKeepAliveTimeSeconds";

          ...

          long executorKeepAliveTimeSeconds = 60;

          ...

          value = servletContext.getInitParameter(

          Constants.EXECUTOR_KEEPALIVETIME_SECONDS_INIT_PARAM);

          if (value != null) {

               executorKeepAliveTimeSeconds = Long.parseLong(value);

          }

           

          This code taken from: [jbossweb-commits] JBossWeb SVN: r2299 - in branches/7.4.x/src/main/java/org: jboss/web and 1 other directory.

           

          So perhaps JBoss isn't supplying a param called "org.apache.tomcat.websocket.executorKeepAliveTimeSeconds" and so a default of 60 seconds is used?

           

          Am I barking up the wrong tree?  Surely I can't be the only person who has tried keeping a Websocket open on JBoss EAP 6.3 for longer than 60 seconds?

           

          I want to figure-out how to set the "org.apache.tomcat.websocket.executorKeepAliveTimeSeconds" value, but I don't know how.  Plus, what value would I set it to? (-1, 0, 99999999999999999)?

           

          Does anyone have any ideas?

           

          Thanks.

          • 2. Re: WebSocket connection closes after 65 seconds no matter what
            ammt

            Hi David,

             

            I have the same problem, and I resolved it sending a ping message (session.getBasicRemote().sendPing(buffer)) every 60 seconds.

             

            I know it's not very efficient, but it is the only thing that worked for me

            • 3. Re: WebSocket connection closes after 65 seconds no matter what
              davidj

              Hi Andrea,

              It is useful to learn that someone else is having the same problem; at least now we know individual configuration isn't the problem. Thanks.

               

              The corporation I work for has finally purchased a Support Agreement with Red Hat, so I am able to create a support ticket with Red Hat which hopeful will require the engineers to investigate this issue (since obviously they aren't looking at it now).

               

              - David

              • 4. Re: WebSocket connection closes after 65 seconds no matter what
                jaikiran

                Moved to the right forum which WildFly/EAP developers watch.

                • 5. Re: WebSocket connection closes after 65 seconds no matter what
                  davidj

                  My employer received a response from Red Hat; the news isn't good.  I was correct earlier in this thread where I talked about the "keepAliveTimeout" being set to 60 seconds.  Therefore, a websocket connection is closed in 60 seconds.  Red Hat also informed us that "websocket is tech preview which mean we don't suggest customer use this feature in production environment".  This is unfortunate because I'll need to re-design my current task.  "Tech Preview" is a double-edged sword, on one hand it is nice to get earlier access to exciting new functionality, but on the other hand, if the new functionality doesn't work there's nothing gained.

                   

                  Hopefully JBoss EAP 6.3.1 will soon be released with a fix.

                  • 6. Re: WebSocket connection closes after 65 seconds no matter what
                    ctomc

                    David Jensen wrote:

                     

                    Hopefully JBoss EAP 6.3.1 will soon be released with a fix.

                    6.3.2 was already released... you can grab patches to upgrade 6.3.0 to it in customer portal.

                    1 of 1 people found this helpful
                    • 7. Re: WebSocket connection closes after 65 seconds no matter what
                      davidj

                      Thanks Tomaz. I appreciate the heads-up. I usually only check the public site, and 6.3.2 isn't yet available.  I just logged-in thru the customer portal and verified it is available there.

                       

                      Do you know if this issue is fixed in the update?

                       

                      Thanks

                      • 8. Re: WebSocket connection closes after 65 seconds no matter what
                        davidj

                        I have obtained JBoss EAP 6.3.2 (as a patch), but unfortunately the problem still exists.