-
1. Re: Continous heart beat requests after startup
jfuerth Jan 24, 2013 12:38 PM (in response to ganeshkumar)1 of 1 people found this helpfulHi Ganesh,
Thanks for your question!
Right off the top, I recommend you update to 2.2.0.CR2, our latest release. There have been a lot of bug fixes since 2.0.2.Final. Further, the rest of the advice in this response refers to new APIs that were introduced after 2.0.2.
Errai no longer uses actual heartbeat messages, but as you've observed, it does commence long-polling the server as soon as the page loads.
If you don't want Errai to communicate with the server at all, you can set a javascript variable in the page header. See https://docs.jboss.org/author/display/ERRAI/Client+Configuration for details.
If you instead want Errai to defer its handshake with the server until some time specified by the application, you can use the new bus lifecycle API. You can call stop() on the ClientMessageBus to tell it not to connect back to the server. If you do this early enough in the app lifecycle, you might be able to prevent even the initial handshake request. When you do want the bus to connect to the server, call ClientMessageBus.init(). Of course, stop() and init() act asynchronously. You can monitor the connection status using a BusLifecycleListener.
-Jonathan
-
2. Re: Continous heart beat requests after startup
ganeshkumar Jan 24, 2013 11:17 PM (in response to jfuerth)Thanks Jonathan for you reply.
I have some questions:
If you instead want Errai to defer its handshake with the server until some time specified by the application, you can use the new bus lifecycle API.
Is this new API available in 2.0.2?
You can call stop() on the ClientMessageBus to tell it not to connect back to the server. If you do this early enough in the app lifecycle, you might be able to prevent even the initial handshake request.
Does this mean that even if I call stop(), there is still a chance that handshake requests are sent? What is the guaranteed way to stop the initial handshake?
Thanks,
Ganesh
-
3. Re: Continous heart beat requests after startup
jfuerth Jan 25, 2013 10:48 AM (in response to ganeshkumar)Hi Ganesh,
No, none of the features mentioned in my reply existed yet in 2.0.2. I recommend you update to 2.2.0.CR2, our latest release. There have been a lot of bug fixes since 2.0.2.Final. Further, the rest of the advice in this response refers to new APIs that were introduced after 2.0.2.
You can call stop() on the ClientMessageBus to tell it not to connect back to the server. If you do this early enough in the app lifecycle, you might be able to prevent even the initial handshake request.Does this mean that even if I call stop(), there is still a chance that handshake requests are sent? What is the guaranteed way to stop the initial handshake?
If this is important to you (I'm interested in your use case--why is it critical that no AJAX request is made when the page loads?) then you would need to combine both approaches.
First, set window.erraiBusRemoteCommunicationEnabled = false in a <script> tag in the page header. This guarantees the bus will not attempt any AJAX requests.
Then, when you are ready to begin server communication, set window.erraiBusRemoteCommunicationEnabled = true (you will need to use JSNI for this; there's no GWT API in Errai for setting the variable) and then call bus.init().
Note that we are not aware of anyone else who has attempted to do this before. You may run into edge cases where it doesn't work. Please let us know if you needed to apply any additional workarounds not listed here!
-Jonathan