AP
Nov 13, 2018Nimbostratus
Hi Niels,
Have you seen any unhandled errors during network outage events? I've seen a couple since implementing a solution based on your v0.3 iRule (obtained via Brett).
Error during network outage:
err sdmd[6365]: 018e0018:3: pid[12638] plugin[/Common/office365_ipi_PROD_plugin.office365_ipi_extension] events.js:160
err sdmd[6365]: 018e0018:3: pid[12638] plugin[/Common/office365_ipi_PROD_plugin.office365_ipi_extension] throw er; // Unhandled 'error' event
err sdmd[6365]: 018e0018:3: pid[12638] plugin[/Common/office365_ipi_PROD_plugin.office365_ipi_extension] ^
err sdmd[6365]: 018e0018:3: pid[12638] plugin[/Common/office365_ipi_PROD_plugin.office365_ipi_extension]
err sdmd[6365]: 018e0018:3: pid[12638] plugin[/Common/office365_ipi_PROD_plugin.office365_ipi_extension] Error: connect EHOSTUNREACH
Another variation of the last line. Presumably a DNS issue:
err sdmd[23042]: 018e0018:3: pid[812] plugin[/Common/office365_ipi_PROD_plugin.office365_ipi_extension] Error: getaddrinfo EAI_AGAIN endpoints.office.com:443
So the above issues ultimately end in the extension being terminated after it's maximum restart attempts. I'm looking at a few ways to improve this, however to begin with, your error handling actually looks fine, so I'm not sure why I get an unhandled error:
res.on('error', function(e) {
callback(e, null);
});
Complete function:
// helper to call the webservice
function getJson(methodName, instanceName, clientRequestId, callback) {
var ws = "https://endpoints.office.com";
var requestPath = ws + '/' + methodName + '/' + instanceName + '?clientRequestId=' + clientRequestId;
var req = https.get(requestPath, function(res) {
var data = '';
res.on('data', function(chunk) {
data += chunk;
});
res.on('error', function(e) {
callback(e, null);
});
res.on('timeout', function(e) {
callback(e, null);
});
res.on('end', function() {
if(res.statusCode == 200) {
callback(null, data);
}
});
});
}
Any thoughts?