猿问

javascript 的socket 报出的“200”错误,怎么解决

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);
};


手掌心
浏览 7101回答 6
6回答

FFIVE

response code 200说明正常,,,http状态返回代码 1xx(临时响应)http状态返回代码 2xx (成功)http状态返回代码 3xx (重定向)http状态返回代码 4xx(请求错误)http状态返回代码 5xx(服务器错误)

SMILET

这里感觉应该是你的代码错误,因为200是握手成功的,会不会是你的浏览器不知此es6的写法
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答