Skip to content

Commit

Permalink
fixes socketio#555
Browse files Browse the repository at this point in the history
  • Loading branch information
einaros committed Oct 22, 2011
1 parent 120924f commit bee1efb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
16 changes: 14 additions & 2 deletions lib/transports/websocket/hybi-07-12.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ function WebSocket (mng, data, req) {
});
this.parser.on('ping', function () {
// version 8 ping => pong
self.socket.write('\u008a\u0000');
try {
self.socket.write('\u008a\u0000');
}
catch (e) {
self.end();
return;
}
});
this.parser.on('close', function () {
self.end();
Expand Down Expand Up @@ -177,7 +183,13 @@ WebSocket.prototype.verifyOrigin = function (origin) {
WebSocket.prototype.write = function (data) {
if (this.open) {
var buf = this.frame(0x81, data);
this.socket.write(buf, 'binary');
try {
this.socket.write(buf, 'binary');
}
catch (e) {
this.end();
return;
}
this.log.debug(this.name + ' writing', data);
}
};
Expand Down
16 changes: 14 additions & 2 deletions lib/transports/websocket/hybi-16.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ function WebSocket (mng, data, req) {
});
this.parser.on('ping', function () {
// version 8 ping => pong
self.socket.write('\u008a\u0000');
try {
self.socket.write('\u008a\u0000');
}
catch (e) {
self.end();
return;
}
});
this.parser.on('close', function () {
self.end();
Expand Down Expand Up @@ -177,7 +183,13 @@ WebSocket.prototype.verifyOrigin = function (origin) {
WebSocket.prototype.write = function (data) {
if (this.open) {
var buf = this.frame(0x81, data);
this.socket.write(buf, 'binary');
try {
this.socket.write(buf, 'binary');
}
catch (e) {
this.end();
return;
}
this.log.debug(this.name + ' writing', data);
}
};
Expand Down

0 comments on commit bee1efb

Please sign in to comment.