4 Replies Latest reply on Jul 25, 2014 5:53 PM by csa

    ErraiBus and Server Side Events (SSE)

    timeu

      I have been using ErraiBus (version 2.3.0.Final) as a standalone dependency in my GWT application for push notifications and it worked flawless.

       

      Recently I updated to the latest version 2.4.4.Final and the push notifications (server -> client) stopped to work. The only difference as far as I can tell is that instead of LongPolling in the new version Server Side Events are used.

       

      I am using the DefaultBlockingServlet in Jetty 8.1. According to the console the SSE is properly setup and validated.

      However it seems that the callback on the client is not executed.

       

      web.xml code:

       

          <servlet>

              <servlet-name>ErraiServlet</servlet-name>

              <servlet-class>org.jboss.errai.bus.server.servlet.DefaultBlockingServlet</servlet-class>

              <init-param>

                  <param-name>auto-discover-services</param-name>

                  <param-value>true</param-value>

              </init-param>

              <load-on-startup>1</load-on-startup>

          </servlet>

         <servlet-mapping>

              <servlet-name>ErraiServlet</servlet-name>

              <url-pattern>*.erraiBus</url-pattern>

          </servlet-mapping>

       

      Client side code:

          MessageBus messageBus = ErraiBus.get();

          messageBus.subscribe("BroadcastReceiver", new MessageCallback() {

                  @Override

                  public void callback(Message message) {

                      logger.log(Level.INFO,"Event receiver");

                  }

              });

       

      Server side code:

       

      MessageBuilder.createMessage("BroadcastReceiver")

              .signalling()

              .noErrorHandling()

              .sendNowWith(dispatcher);

        • 1. Re: ErraiBus and Server Side Events (SSE)
          csa

          Hi Uemit,

           

          We recently ran into the same issue using JavaFx's WebView as a browser and Jetty 8 with SSE. We were not able to reproduce it on other browser's though. What browser did you test this with? Did you try in both DevMode and production mode?

           

          One solution you can use right away is to deactivate SSE and make the bus use long polling instead. Simply add this to your ErraiService.properties file:

          errai.bus.enable_sse_support=false

           

          If you find any more details about what might be causing this please let us know!

           

          Cheers,

          Christian

          • 2. Re: ErraiBus and Server Side Events (SSE)
            timeu

            Hi Christian,

             

            Thanks for the feedback. The Issue happened in both Firefox and Chrome and the behavior is quite erratic.

             

            For example I added button to the web-app that when pressedit  sends a message to the server (via erraibus) and in the callback I send a message back  to the client (also via erraibus).

            The message only was delivered when I pressed the button a second time and sometimes it wasn't delivered at all.

             

            I think there might be an issue in the DefaultBlockingServlet but I am not sure.

             

            Thanks for the workaround I will try it.

            • 3. Re: ErraiBus and Server Side Events (SSE)
              timeu

              FYI:

              I recently upgraded Jetty 8 to Jetty 9.1.2 and Errai-Bus from 2.3.0.Final to 3.0.1.Final

               

              With DefaultBlockingServlet and SSE I had the same issue as with 2.4.4.Final.

              When I switched to StandardAsyncServlet (Servlet 3.1) and Long Polling messaging worked again.

              • 4. Re: ErraiBus and Server Side Events (SSE)
                csa

                Hi Uemit,

                 

                I just tested some demos on Jetty 9.2.1 and they worked fine for me using SSE. Can you try this war file (our plain errai bus stock demo) and see if it works for you: http://downloads.jboss.org/errai/dist/3.0.1.Final/errai-bus-demo-stock.war

                 

                Can you paste your app's output from your JavaScript console? Do you see any errors there?

                 

                Cheers,

                Christian