2 Replies Latest reply on Dec 12, 2016 11:57 PM by fobos

    TEXT_FULL_WRITING error in JBoss EAP 6.3 with Web Socket

    davidj

      Hi, I'm using JBoss EAP 6.3 with WebSockets.  The functionality is "hit and miss" meaning sometimes it works, and sometimes it doesn't.  When it doesn't work, I get the following error:

       

      java.lang.IllegalStateException: JBWEB008529: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method

       

      I haven't yet discovered a pattern of when it works and when it doesn't.  Can anyone offer any suggestions?

       

      The code is (stripped-down):

       

      session.getBasicRemote().sendText("hello world"); // session is a "javax.websocket.Session"


      I'm using Java JDK 8 (update 20).


      Thanks.

        • 1. Re: TEXT_FULL_WRITING error in JBoss EAP 6.3 with Web Socket
          davidj

          I found the problem: it was me!

          The problem is with how I stored multiple sessions.  For example, let's suppose that 3 users have established a websocket.  My code was was storing those 3 sessions in a HashSet.  Then, when I wanted to send each of them a message, I would loop thru the Set of sessions and for each one do a: session.getBasicRemote().sendText(message); .  Trouble is: some of those sessions might have been closed.  So I changed my for-loop to have a try/catch block surrounding each "sendText()" call.

           

          WRONG is:

          try {

               for(Session session : sessions) {

                    session.getBasicRemote().sendText(message);

               }

          }

          catch(Exception e) {

          }

           

          CORRECT is:

          for(Session session : sessions) {

               try {

                    session.getBasicRemote().sendText(message);

               }

               catch(Exception e) {

               }

          }

           

          Now it works fine.  But now there's another problem: How will I know a websocket has closed so I can remove it from my Set of sessions?  I thought that when the Javascript called "websocketSession.close()" that the server-side "onClose()" method would get called, but it doesn't.  So how will I know?

           

          Thanks.

          • 2. Re: TEXT_FULL_WRITING error in JBoss EAP 6.3 with Web Socket
            fobos

            Hi David,

            have you solved the problem with ghost websocket sessions ??

             

            Thanks