Skip to content

websocket proxy,what if the sever reject the connect with status other than 101 #624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iamzfj opened this issue Apr 21, 2014 · 3 comments · Fixed by #708
Closed

websocket proxy,what if the sever reject the connect with status other than 101 #624

iamzfj opened this issue Apr 21, 2014 · 3 comments · Fixed by #708

Comments

@iamzfj
Copy link

iamzfj commented Apr 21, 2014

websocket proxy,if the sever reject the connect with status other than 101,then the proxy req will not emmit an upgrade event,and the connection from client will hong on by the proxy for a long long time!
maybe the proxy should also catch the response event!

@jcrugzz
Copy link
Contributor

jcrugzz commented Apr 21, 2014

@iamzfj can you show me an example of this case? More test cases always help :)

@kd128
Copy link

kd128 commented Apr 21, 2014

i have use another account name kd128 instead of iamzfj ^_^
recently,i am using https://github.com/Worlize/WebSocket-Node for ws server,
and found this bug!
in WebSocket-Node,before accept an ws request from client,ws server may reject it!
what about
WebSocketRequest.prototype.reject = function(status, reason, extraHeaders) {
if (typeof(status) !== 'number') {
status = 403;
}
var response = "HTTP/1.1 " + status + " " + httpStatusDescriptions[status] + "\r\n" +
"Connection: close\r\n";
if (reason) {
reason = reason.replace(headerSanitizeRegExp, '');
response += "X-WebSocket-Reject-Reason: " + reason + "\r\n";
}

if (extraHeaders) {
    for (var key in extraHeaders) {
        var sanitizedValue = extraHeaders[key].toString().replace(headerSanitizeRegExp, '');
        var sanitizedKey = key.replace(headerSanitizeRegExp, '');
        response += (sanitizedKey + ": " + sanitizedValue + "\r\n");
    }
}

response += "\r\n";
this.socket.end(response, 'ascii');

this.emit('requestRejected', this);

};

code from
https://github.com/Worlize/WebSocket-Node/blob/master/lib/WebSocketRequest.js

@kd128
Copy link

kd128 commented Apr 25, 2014

please fix this bug as soon as possible,because it will make socket leave!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants