WindowsAzure/azure-sdk-for-node — Issue #79: socket hang up error when running in a tight loop
Author: turanuk
Created: 2012-02-16 03:14:49+00:00
State: open

The repro code runs a call to getMessages from a queue service in a tight loop. Eventually you will get to an error where the socket has hung up which looks like this:

events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: socket hang up
at createHangUpError (http.js:1104:15)
at Socket.onend (http.js:1167:27)
at TCP.onread (net.js:369:26)

At which point your role needs to recover from the crash. Is this some kind of throttling from Azure? Can we possibly handle this better?

Repro code:

var azure = require('azure')

var quickQueueService = azure.createQueueService();

//MAIN CODE FLOW
var eventLoop = function () {
quickQueueService.getMessages('foo', function(err, message) {
if(!err) {
console.log(new Date() + ' Success');
} else {
console.log(new Date() + 'Failure');
}
});
}
try {
setInterval(eventLoop, 5);
} catch (e) {
console.log('Error');
}