Meteor.status().status connecting forever


#1

Hello guys, is there a way to recover client connections?

For some reason, when my app is rendered Meteor.status().status is connected but after few seconds the status down to waiting and goes to connecting and still connecting forever…

I tried to solve the problem forcing reconnection but it doesn’t work

var intervalId = null;
Meteor.startup(function() {
    Tracker.autorun( function () {
        if(Meteor.status().status === "waiting" && intervalId === null) {
            intervalId = Meteor.setInterval( function () {
                Meteor.reconnect()
            }, 1000);
        }
        if(Meteor.status().status === "connected" && intervalId != null) {
            Meteor.clearInterval(intervalId);
            intervalId = null;
        }
    })
});

So, just to help with any suggestions, this is my route:

FlowRouter.route('/operador/validacao/',{
    subscriptions: function(params, queryParams) {
        this.register('transactions', Meteor.subscribe('CordovaTransactions'));
    },
    action: function(params) {
        FlowLayout.render('Private', {main: "TicketValidation"});
    }
});

And the code that needs to talk with the server

function scan(){
    cordova.plugins.barcodeScanner.scan(
        function (result) {
            var transactionId = result.text;
            if(transactionId){
                var transaction = Transactions.findOne({_id:transactionId});
                var quantity = parseInt(transaction.quantity);
                if(quantity>0){
                    alert("Ingresso válido!")
                    var remainder = quantity-1;
                    Transactions.update({_id:transactionId},{$set:{quantity:remainder}})
                }else{
                    alert("Ingresso inválido!")
                }
            }else{
                alert("Não foi possível verificar o ingresso!")
            }
        },
        function (error) {
            alert("Não foi possível verificar o ingresso!");
        }
    );
}

Template.TicketValidation.events({
    'click .scan':function(e){
        e.preventDefault();
        alert('meteor is '+ Meteor.status().status)
        scan();
    }
});

Thank you!


#2