WebSocket connection to 'ws://127.0.0.1:8020/' failed: Error during WebSocket handshake: Unexpected response code: 200
握手信息200是错误???不是很懂
以下是出事故的代码:
connect : function(url) {
// Websocket initialization
if (this.ws != undefined) {
this.ws.close();
delete this.ws;
}
this.ws = new WebSocket(url); //<==there is a error O~O
this.ws.binaryType = "arraybuffer";
this.ws.onopen = () => {
log("Connected to " + url);
};
response code 200说明正常,,,
http状态返回代码 1xx(临时响应)
http状态返回代码 2xx (成功)
http状态返回代码 3xx (重定向)
http状态返回代码 4xx(请求错误)
http状态返回代码 5xx(服务器错误)
undefined应该是字符串吧
this.ws != ‘undefined’
http://blog.csdn.net/zixiao217/article/details/53098700
相应200不是错,但是返回之后执行的代码可能出了错!!!你仔细看看握手之后已改执行哪些代码? 比如
this.ws.onopen = () => {
log("Connected to " + url);
};
中有个‘=>’是啥?
这里感觉应该是你的代码错误,因为200是握手成功的,会不会是你的浏览器不知此es6的写法