Skip to content

Commit

Permalink
Catch DNS errors from UDP socket
Browse files Browse the repository at this point in the history
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
  • Loading branch information
YarekTyshchenko committed Feb 6, 2013
1 parent 187697c commit a636fc2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backends/repeater.js
Expand Up @@ -7,7 +7,10 @@ function RepeaterBackend(startupTime, config, emitter){
this.sock = (config.repeaterProtocol == 'udp6') ?
dgram.createSocket('udp6') :
dgram.createSocket('udp4');

// Attach DNS error handler
sock.on('error', function (err) {
console.log('Repeater error: ' + err);
});
// attach
emitter.on('packet', function(packet, rinfo) { self.process(packet, rinfo); });
};
Expand Down

0 comments on commit a636fc2

Please sign in to comment.