Catch DNS errors from UDP socket

If repeater is used with hostnames rather than IPs
a DNS resolution error crashes statsd server.
If you have a chain of statsd servers configured
to repeat data down the line this has the potential
to bring down the entire chain.

Attaching an error handler stops dgram socket from
throwing an exception and instead logs to console
This commit is contained in:
Yarek T 2013-02-06 13:40:18 +00:00
Родитель 187697cd21
Коммит a636fc2383
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -7,7 +7,10 @@ function RepeaterBackend(startupTime, config, emitter){
this.sock = (config.repeaterProtocol == 'udp6') ? this.sock = (config.repeaterProtocol == 'udp6') ?
dgram.createSocket('udp6') : dgram.createSocket('udp6') :
dgram.createSocket('udp4'); dgram.createSocket('udp4');
// Attach DNS error handler
sock.on('error', function (err) {
console.log('Repeater error: ' + err);
});
// attach // attach
emitter.on('packet', function(packet, rinfo) { self.process(packet, rinfo); }); emitter.on('packet', function(packet, rinfo) { self.process(packet, rinfo); });
}; };