cayasso / mongo-oplog

Watch mongodb oplog in a simple way
381 stars 91 forks source link

Upgraded from working version 1.1.0 to 2.0.2 and no longer receiving 'update' messages #46

Open jbockerstette opened 7 years ago

jbockerstette commented 7 years ago

I upgraded from 1.1.0 to 2.0.2 and my working code no longer received callbacks for 'update' messages. The code works fine when using 1.1.0 but does not work in version 2.0.2. I verified that I can connect to mongo and tail without error in version 2.0.2. However, I no longer received any callbacks for changes to my collections. I followed your upgrade procedure and nothing is crashing, but I no longer get any updates. I rolled back to 1.1.0 and now everything works again. I use a filter so that I can get updates for only the collection I want like so:

var tagsFilter = oplog.filter('*.tags');
tagsFilter.on('update', callback);
cayasso commented 7 years ago

Hi @jbockerstette Does it work without filter? Can you try that just to see if its only the filter?

jbockerstette commented 7 years ago

I tried this in both 1.1.0 and 2.0.2. It works fine in 1.1.0 but not in 2.0.2. The only callback I get is the tail callback and the oplog.stop callback.

oplog = MongoOplog('mongodb://swagger:swagger1234@localhost:27017/local?authSource=Apple&ssl=true',
            {ns: 'Apple',
                server: {
                    sslValidate:true,
                    sslCA:ca
            }});
oplog.tail();
oplog.on('update', function (doc) {
        console.log("Got an update.");
 });
doktoroblivion commented 6 years ago

I am also trying to use 2.0.2 and seeing similar issues. However, I am using a replica set with TLS encryption and was trying to figure out if that would have anything to do with it as well. I am not seeing any inserts and no errors.

pinnprophead commented 6 years ago

Just wondering if you have an on("error",... handler set up and/or an on("end"... Maybe that would give a clue as to why?

doktoroblivion commented 6 years ago

Sorry, should have updated this, I got it to work. It all comes down to making sure you are connected to the 'local' DB so that the oplog collection is available.

raybellis commented 5 years ago

I'm also experiencing this with 2.1.4, and in my case it appears to be because of the use of the ns field in the options. If I remove it everything works fine.