5 Replies Latest reply on Nov 29, 2011 3:14 PM by Emerson Pardo

    Comet 8kb limit

    Emerson Pardo Newbie

      Hi all,

       

      I'm developing a solution to send updates to my clients using comet. All works fine (i followed the example at  http://docs.jboss.org/jbossweb/3.0.x/aio.html ) except when the message (each message is just a string) sent are bigger than 8kb. In this case it seems the outputStream freeze and doesn't send the rest of the string. It blocks indefinitly and no exceptions occurs.

       

      I tried to find some configuration to increase the outputStream internal buffer but didn't find one.

       

      Any ideas on how to solve this?

       

      Thanks in advance.

        • 1. Re: Comet 8kb limit
          Jean-Frederic Clere Master

          if the write blocs you have to use event.isWriteReady() to test if you can write and if not wait for the WRITE event.

          • 2. Re: Comet 8kb limit
            Emerson Pardo Newbie

            Hi Jean-Frederic! Thanks for the response.

             

            I followed the initial example and put all the write processing inside a thread like MessageSender and the events are triggered inside HttpServletEvent. Is there any example explaning how to use event.isWriteReady() out there?   

             

            Thanks again!

            • 3. Re: Comet 8kb limit
              Jean-Frederic Clere Master

              I am using something like:

              while (event.isWriteReady()) {

                   os.println("bla");

              }

               

              and I have a logic in the case WRITE

              switch (event.getType()) {

                ....

                   case WRITE:

                        /* write more ? */

                        break;

              1 of 1 people found this helpful
              • 4. Re: Comet 8kb limit
                Emerson Pardo Newbie

                Jean-Frederic,

                 

                I'll try this and post here if it works.

                 

                Thanks!

                Jean-Frederic Clere wrote:

                 

                I am using something like:

                while (event.isWriteReady()) {

                     os.println("bla");

                }

                 

                and I have a logic in the case WRITE

                switch (event.getType()) {

                  ....

                     case WRITE:

                          /* write more ? */

                          break;

                • 5. Re: Comet 8kb limit
                  Emerson Pardo Newbie

                  It's worked!

                   

                  My code look like the following, inside my thread I have to do this:

                   

                  private Semaphore sem = new Semaphore(0);

                   

                  void writeMessage(String message){

                    byte[] msg = message.getBytes();

                    for(byte b:msg){

                       if(!event.isWriteReady())

                         sem.acquire();

                       writer.write(b);

                     }

                  }

                   

                  void notifyWrite(){

                      sem.release();

                  }

                  }

                   

                  And insite HttpServletEvent in the case WRITE:

                   

                    case WRITE:

                        myThread.notifyWrite();

                   

                   

                  Thanks for the help, Jean-Frederic.

                   

                  Emerson Pardo wrote:

                   

                  Jean-Frederic,

                   

                  I'll try this and post here if it works.

                   

                  Thanks!

                  Jean-Frederic Clere wrote:

                   

                  I am using something like:

                  while (event.isWriteReady()) {

                       os.println("bla");

                  }

                   

                  and I have a logic in the case WRITE

                  switch (event.getType()) {

                    ....

                       case WRITE:

                            /* write more ? */

                            break;