Skip to content

Commit

Permalink
Merge pull request #6 from wjlroe/proxy-connection-errors
Browse files Browse the repository at this point in the history
Proxy TCP/UDP errors on to client object
  • Loading branch information
perezd committed Apr 15, 2013
2 parents 0f8cf2d + a8c0c16 commit fd49814
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions riemann/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ function Client(options, onConnect) {
// proxy the TCP connect event.
this.tcp.socket.on('connect', function() { self.emit('connect'); });

// proxy errors from TCP and UDP
this.tcp.socket.on('error', function(error) { self.emit('error', error); });
this.udp.socket.on('error', function(error) { self.emit('error', error); });

this.tcp.onMessage(function(message) {
self.emit('data', Serializer.deserializeMessage(message));
});
Expand Down
7 changes: 7 additions & 0 deletions test/basic_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ test("should connect to server", function(done) {
});


var server_down;
test("should fire error event", function(done) {
server_down = require('riemann').createClient({port: 66500});
server_down.on('error', done);
});


test("should send an event as udp", function(done) {
client.send(client.Event({
service : 'hello_udp',
Expand Down

0 comments on commit fd49814

Please sign in to comment.