Reputation: 49
I would like to use vertx eventbus from Javascript client (mainly smartphones). My problem is when I send the phone to standby, the eventbus disconnects after a couple of seconds and doesn't reconnect after wake up. I try to reconnect in eventbus onclose(), but it doesn't always work. Any ideas?
Upvotes: 2
Views: 1875
Reputation: 774
This functionality has been added to working version of vert.x, but is not yet official. However, you can import and use vertx-eventbus.js
:
https://github.com/vert-x3/vertx-web/pull/660
After you initialize the EventBus with e.g. var eb = new EventBus("/eventbus");
, you can enable it with eb.enableReconnect(true);
Upvotes: 1
Reputation: 6188
Instead of trying reconnection only once, why don't you try to reconnect in a loop:
eventBus.onclose = function {
while(state != vertx.EventBus.OPEN) {
setInterval(function(){
// Recreate an eventbus object and re-register all callbacks included this one
initialiseEventbus()
},3000);
}
}
The above is not the most elegant solution, but unfortunately there's no (re)connect method to call on vertxbus.js, nor a default automatic reconnection strategy. That's a pity, but I'm sure the dev team would happy to accept a ticket on this.
Upvotes: 1