couchdb tracking changes timeout

451 views Asked by At

I'm writing a small node server, hosted in nodejitsu, that fetchs changes continuously from a cloudant db that's being modified all the time.

I'm using the follow module, that provides an interesting couchdb changes fetcher. The problem I'm having is that I want the server to work without reboots. I mean, to work continuously, non-stop. But I've found that sometimes my nodejitsu server is rebooted. For example, I left it yesterday working at 3:30 pm, and it got rebooted today around 8 am. I've discovered that the 'death' of the server happens when a timeout event is triggered by the follow module. I think I should handle this event, but I don't know how. This timeout is related, I think, to the heartbeat from cloudant.

I have written something like:

feed.on('timeout', function (err){
    console.log("Timeout!");
});

And the changes are fetched this way:

var feed = new follow.Feed({db:"https://"+user+":"+password+"@"+host+"/"+dbSource,since:"now",filter:"sync/notSynchronizedFilter"});

feed.on('change',function (change){
    //...do stuff
});

EDIT: There is an interesting thing. Right after the timeout event is triggered, an error occurs:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: getaddrinfo ENOTFOUND
    at errnoException (dns.js:37:11)
    at Object.onanswer [as oncomplete] (dns.js:124:16)

EDIT 2: More info.

I 've finally changed the heartbeat to 5 minutes, to make it very difficult to get the timeout. This kind of solved my particualr problem, but doesn't answer the original question. Regarding the error, I think it might have to do with the 'follow' module (I mean a bug), but I'm not sure.

Thanks in advance!!

Bruno.

0

There are 0 answers