Closed calendee closed 9 years ago
I finally made a little progress on this. I've got a good Nodefire connection to my Firebase. I've assigned a worker and modified the firelease source to console its arguments.
I get this :
Queue=
{ '0': 'https://MY-FIREBASE-NAME-HERE.firebaseio.com/workQueue',
'1':
{ maxConcurrent: 2,
bufferSize: 5,
minLease: 5000,
maxLease: 25000 },
'2': [Function: processWorkQueue] }
So, I think I'm on the right path. However, the processWorkQueue
function never gets called even though there are items in the workQueue.
Any ideas?
Hey @calendee, looks like you're doing it right so not sure what's going on. There's no error messages on the console? Are any items in /workQueue
getting a _lease
child added, at least? Do you see the queue being pinged at 5-minute intervals with the results written to the console?
Are you sure you're getting connected to your Firebase? Perhaps add this snippet to your code to check (where db
is a top-level NodeFire or Firebase instance):
db.child('.info/connected').on('value', function(snap) {
console.log('Firebase', db.toString(), snap.val() ? 'CONNECTED' : 'DISCONNECTED');
});
Apologies for the somewhat sparse documentation, I've been using this module only internally so far.
@pkaminski Thanks for the response.
This is how I'm connecting:
var NodeFire = require('nodefire');
NodeFire.setCacheSize(10);
NodeFire.DEBUG = true;
fbRef = new NodeFire(config.fireBaseUrl);
fbRef.auth(fbToken).then(
function(success) {
console.log("Authenticated");
console.log(success);
callback();
}, function(err) {
console.log("Failed To Authenticate");
console.log(err);
callback(err);
}
);
I get a result like this:
Authenticated
{ auth: { uid: 'test-firelease' },
expires: 1423440000,
token: 'ayJ0eXA....PCvkCWKj',
uid: 'test-firelease',
provider: 'custom' }
Something very odd must be going on. Your auth code looks correct (assuming the FireLease connections take place in the callback()
and use fbRef.child('workQueue')
), but I've never seen it work and the .info/connected
handler not fire. Can you read/write through fbRef
in the callback()
?
If none of this helps, I'll put together a simple demo this afternoon to see if you can repro the problem, and perhaps do a differential debug.
Here's the simplest possible demo code that I confirmed runs on my machine:
var NodeFire = require('nodefire');
var firelease = require('firelease');
var db = new NodeFire('https://firelease-test.firebaseio.com/');
firelease.attachWorker(db.child('queue'), function(item) {
console.log('Hello', item.name);
});
setInterval(function() {
db.child('queue').push({name: 'World'});
}, 2000);
Can you check if this works for you too, then progressively convert it into your program (switch to your Firebase, add auth, etc.) and see at what point it breaks?
Thanks so much. That got me rolling. Was mistakenly using the firebase URL in the attachWorker
instead of the reference to the db.
Can you provide an example of using firelease? I can't seem to work out how to 1) Get a reference with nodefire and 2) pass this reference to firelease.