Skip to content

Commit

Permalink
improved error handling for tcp bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
grs committed Sep 4, 2019
1 parent 3280396 commit df71e9a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/tunnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function Server(receiver, socket) {
this.receiver.on('session_close', this.on_session_close.bind(this));
this.socket.on('data', this.on_socket_data.bind(this));
this.socket.on('end', this.on_socket_end.bind(this));
this.socket.on('error', this.on_socket_error.bind(this));
}

Server.prototype.on_message = function (context) {
Expand Down Expand Up @@ -180,6 +181,11 @@ Server.prototype.on_socket_end = function (data) {
process.nextTick(this.close.bind(this));
};

Server.prototype.on_socket_error = function (error) {
console.error(error);
process.nextTick(this.close.bind(this));
};

Server.prototype.close = function () {
this.receiver.close();
if (this.sender) {
Expand Down

0 comments on commit df71e9a

Please sign in to comment.