5 Replies Latest reply on Mar 3, 2014 7:02 PM by Christian Sadilek

    ClientMessageBusImpl [connection interrupted error]

    Saif Rehman Newbie

      Hi Guys,

      I have an application using errai. I m getting the following ClientMessageBusImpl error while performing some specific functions in the app. Like (create , edit ) . Once the error occurred the app starts behaving strangely (doesn't load content on the page) .

      Note: All of this happens during a single session . When I logged out and Login again The App looks fine and loads all the content. But again , when I perform (create / edit ) functions , and the cycle continues.

       

      [INFO] ob20:10:18 WARNING [ClientMessageBusImpl] the connection to the server has been interrupted ...

      [INFO] 20:10:19 INFO [HttpPollingHandler] attempting Tx reconnection -- attempt: 1

      [INFO] 20:10:19 INFO [ClientMessageBusImpl] the connection has resumed.

      [INFO] 20:10:19 WARNING [ClientMessageBusImpl] the connection to the server has been interrupted ...

      [INFO] 20:10:20 INFO [HttpPollingHandler] attempting Tx reconnection -- attempt: 2

      [INFO] 20:10:20 INFO [ClientMessageBusImpl] the connection has resumed.

      [INFO] 20:10:21 WARNING [TemplateUtil] WARNING: Replacing Element type [LABEL] with type [SPAN]

      [INFO] 20:10:22 WARNING [ClientMessageBusImpl] the connection to the server has been interrupted ...

      [INFO] 20:10:22 INFO [HttpPollingHandler] attempting Tx reconnection -- attempt: 3

      [INFO] 20:10:23 INFO [HttpPollingHandler] attempting Tx reconnection -- attempt: 4

      [INFO] 20:10:25 INFO [HttpPollingHandler] attempting Tx reconnection -- attempt: 5

      [INFO] 20:10:26 INFO [HttpPollingHandler] attempting Tx reconnection -- attempt: 6

       

      Any help is highly appreciated.

      Thanks

        • 1. Re: ClientMessageBusImpl [connection interrupted error]
          Christian Sadilek Master

          Hi Saif,

           

          We need to find you why the client loses its connection to the server. Can you check the network tab in your Chrome Developer Tools or in Firebug and look for errors? Is there an error code returned from the server or is the server simply unreachable?

           

          Also, which version of Errai are you using?

           

          Cheers,

          Christian

          • 2. Re: ClientMessageBusImpl [connection interrupted error]
            Saif Rehman Newbie

            HI Chris,

            Thanks for the Response!

            I m using <errai.version>3.0-SNAPSHOT</errai.version> .

            The Chrome Network tab says :

            <html>

            <head>

            <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>

            <title>Error 500 INTERNAL_SERVER_ERROR</title>

            </head>

            <body><h2>HTTP ERROR: 500</h2><pre>INTERNAL_SERVER_ERROR</pre>

            <p>RequestURI=/out.76054-48763.erraiBus</p><h3>Caused by:</h3><pre>java.lang.NullPointerException

                at org.jboss.errai.marshalling.client.marshallers.ListMarshaller.doDemarshall(ListMarshaller.java:47)

                at org.jboss.errai.marshalling.client.marshallers.ListMarshaller.doDemarshall(ListMarshaller.java:34)

                at org.jboss.errai.marshalling.client.marshallers.AbstractCollectionMarshaller.doDemarshall(AbstractCollectionMarshaller.java:48)

                at org.jboss.errai.marshalling.client.marshallers.AbstractCollectionMarshaller.doDemarshall(AbstractCollectionMarshaller.java:33)

                at org.jboss.errai.marshalling.client.marshallers.AbstractBackReferencingMarshaller.demarshall(AbstractBackReferencingMarshaller.java:76)

                at org.jboss.errai.marshalling.server.impl.ServerMarshallingFactoryImpl$5.demarshall(ServerMarshallingFactoryImpl.java:814)

                at org.jboss.errai.marshalling.server.impl.ServerMarshallingFactoryImpl$5.demarshall(ServerMarshallingFactoryImpl.java:1)

                at org.jboss.errai.marshalling.server.impl.ServerMarshallingFactoryImpl$90.demarshall(ServerMarshallingFactoryImpl.java:4541)

                at org.jboss.errai.marshalling.server.impl.ServerMarshallingFactoryImpl$90.demarshall(ServerMarshallingFactoryImpl.java:1)

                at org.jboss.errai.marshalling.client.marshallers.AbstractCollectionMarshaller.marshallToCollection(AbstractCollectionMarshaller.java:86)

                at org.jboss.errai.marshalling.client.marshallers.ListMarshaller.doDemarshall(ListMarshaller.java:47)

                at org.jboss.errai.marshalling.client.marshallers.ListMarshaller.doDemarshall(ListMarshaller.java:34)

                at org.jboss.errai.marshalling.client.marshallers.AbstractCollectionMarshaller.doDemarshall(AbstractCollectionMarshaller.java:48)

                at org.jboss.errai.marshalling.client.marshallers.AbstractCollectionMarshaller.doDemarshall(AbstractCollectionMarshaller.java:33)

                at org.jboss.errai.marshalling.client.marshallers.AbstractBackReferencingMarshaller.demarshall(AbstractBackReferencingMarshaller.java:76)

                at org.jboss.errai.marshalling.server.impl.ServerMarshallingFactoryImpl$5.demarshall(ServerMarshallingFactoryImpl.java:814)

                at org.jboss.errai.marshalling.server.impl.ServerMarshallingFactoryImpl$5.demarshall(ServerMarshallingFactoryImpl.java:1)

                at org.jboss.errai.marshalling.client.marshallers.ErraiProtocolEnvelopeMarshaller.doDemarshall(ErraiProtocolEnvelopeMarshaller.java:62)

                at org.jboss.errai.marshalling.client.marshallers.ErraiProtocolEnvelopeMarshaller.demarshall(ErraiProtocolEnvelopeMarshaller.java:39)

                at org.jboss.errai.bus.server.io.MessageFactory.getParts(MessageFactory.java:151)

                at org.jboss.errai.bus.server.io.MessageFactory.createCommandMessage(MessageFactory.java:100)

                at org.jboss.errai.bus.server.servlet.DefaultBlockingServlet.doPost(DefaultBlockingServlet.java:140)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

                at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

                at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)

                at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)

                at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)

                at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)

                at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)

                at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)

                at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)

                at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)

                at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)

                at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)

                at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)

                at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)

                at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)

                at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)

                at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)

                at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)

                at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)

                at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)

                at org.mortbay.jetty.Server.handle(Server.java:324)

                at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)

                at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)

                at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)

                at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)

                at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)

                at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)

                at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

            </pre>

            <p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>                                              

            <br/>                                              

            <br/>  

            I hope this will help.

            The Strange thing is , This happens only on a specific page of the app when I perform an action (e.g save / edit ) . That's where the ClientBus breaks......

             

            Kind regards                       

            • 3. Re: ClientMessageBusImpl [connection interrupted error]
              Christian Sadilek Master

              OK, so the server message bus tries to deliver a message to the client and fails when serializing the payload. We need to find out more. I'd suggest adding a conditional breakpoint (o == null) to ListMarshaller line 47. Then you can go back on the callstack and see which message part caused the problem (MessageFactory line 100).

               

              If you have an example or unit test that demonstrates the problem I can help investigate.

               

              Cheers,

              Christian

              1 of 1 people found this helpful
              • 4. Re: ClientMessageBusImpl [connection interrupted error]
                Saif Rehman Newbie

                Hi Chris,

                The above answer about Putting the break point at ListMarshaller was helpful. Thanks for that !! But my question is that why we don't have a NULL check on ListMarshaller before marshalling or demarshalling ?

                Basically, the error was about marshalling the object on Server/Client Bus which interrupts the connection between server/client bus when a null object is passed to the marshaller (ListMarshaller) to serialize / deserialize .
                We rely on Framework  marshalling / demarshalling during wire communication - and I think its good to rely on that because thats what the frameworks for -

                I put a conditional break point on ListMarshaller (Errai Built-in Marshaller) and I figured  out that its trying to demarshall a NULL object and fails , results in connection interrupted. It also pointed out that the object type is Rule (entity). But from where we are passing it ? I followed the StackTrace but I was unable to find the exact location.
                Infact I already knew that When the error is occurring but Why it is occurring? that's what I m interested in. Let me provide some information on the code.

                Basically we've an entity called Rule, each time when we save/edit/delete a Rule (this is where the error occurred) it fires an event which is observed / listened in different classes to perform some resulting actions like updating the UI, updating the Strategy (another entity) etc. Following is some of the code given:

                RuleEditor class: Rule save event  is fired.

                strategyService.call(new RemoteCallback<Void>() {

                                          @Override

                                          public void callback(Void response) {

                                                JSNIHelper.successNotify("Saved","Rule saved successfully!");

                                                ruleEvent.fireNewItemEvent(srule);

                                          }

                               }

                  ).persistRule(srule);

                ModifyStrategy class : Rule saved event is Observed.

                public void ruleAddedEventHandler(@Observes @Added Rule t) {

                if (t != null && t.getStrategy() != null && t.getStrategy().getId() != null && t.getStrategy().getId().equals(this.selectedStrategy.getStrategy().getId())) {

                Strategy strategy = this.selectedStrategy.getStrategy();

                        strategy.setModifiedDate(new Date());

                        this.strategyService.call(new RemoteCallback<Strategy>() {

                            @Override

                            public void callback(Strategy o) {

                                strategyEvent.fireUpdateItemEvent(o);

                            }

                        }).saveStrategy(strategy);

                  }

                }

                Note: Strategy and Rule has one to many relationship respectively. One Strategy may has 0 or many Rule (s) .

                 

                After that what I did?

                I commented most of the events part and updating logic on ModifyStrategy page (which is invoked after saving a rule). and eventually, came to know that this part of the code is causing the connection interrupted.

                 

                Strategy strategy = this.selectedStrategy.getStrategy();

                        strategy.setModifiedDate(new Date());

                        this.strategyService.call(new RemoteCallback<Strategy>() {

                            @Override

                            public void callback(Strategy o) {

                                strategyEvent.fireUpdateItemEvent(o);

                            }

                        }).saveStrategy(strategy);

                So after this part is commented I m no more getting the connection interrupted error an every thing is fine. I mean to say is that the problem I was facing is resolved now.

                But The Point of the whole discussion is : it took me a long time to figure out that what is the exact cause of the problem because the Errai just says "ErraiBus NullPointerException" . Can we do some more improvements in the marshaller classes to handle these NULL checks and provide a convenient StackTrace of the error.?

                Also I would like to say that you guys are doing a really NICE job !!! Keep up the GOOD WORK !!!

                Thanks once again for the Help !!!

                KInd regards 

                • 5. Re: ClientMessageBusImpl [connection interrupted error]
                  Christian Sadilek Master

                  Hi,

                   

                  I am glad you were able to fix the issue. We can definitely improve the error reporting but I'd prefer to fix the problem instead .

                   

                  From your description I still don't see what causes the issue in ErraiBus/Marshalling. The part of your code you commented out to make the problem go way contains an RPC request and a CDI event that both use the type Strategy. So, I assume it has something to do with marshalling a Strategy instance. Can you share the source of Strategy with us or any more information about the Strategy instance in that case (what fields are null etc.)? Also, is it the CDI event fired in the callback or is it the response to the RPC call that causes the error?

                   

                  Cheers,

                  Christian