I have got a Node.js server querying another server every 10 minutes. Sometimes (~once per month) it crashes with following error:
assert.js:85
throw new assert.AssertionError({
^
AssertionError: null == { Error: getaddrinfo ENOTFOUND zso11.edupage.org zso11.edupage.org:80
at errnoException (dns.js:28:10)
at GetAddrInfoReq
at Request._callback (/home/node/substitutions/myModules/zsoServerComunication.js:150:11)
at self.callback (/home/node/substitutions/node_modules/request/request.js:188:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:189:7)
at Request.onRequestError (/home/node/substitutions/node_modules/request/request.js:884:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:189:7)
at Socket.socketErrorListener (_http_client.js:358:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:189:7)
It happens somewhere here (zsoServerComunication.js):
function getParams(callback){
var url='http://zso11.edupage.org/substitution/?';
request(url,function(err,res,body){
if(!err && res.statusCode ==200){
getGPIDandGSH(body,function(params){ //line 150
var cookie=res.headers['set-cookie'];
var data = {
'gpid':params[0],
'gsh':params[1],
'cookie':cookie
}
saveToCollection(['testCollection',data],function(){
console.log('data added: '+data);
})
});
//save somewhere
}
setImmediate(function() {
callback();
});
});
}
What should I do to fix this error or at least prevent server from crashing?
via Krzysztof DziembaĆa
No comments:
Post a Comment