无法在新的WebSocket上读取未定义的属性'on'

时间:2017-06-05 10:44:29

标签: javascript socket.io engine.io

socket.io@1.7.2

engine.io@1.8.2

创建连接时出现此错误。

TypeError: Cannot read property 'on' of undefined
at new WebSocket (/node_modules/engine.io/lib/transports/websocket.js:28:14)
at Server.handshake (/node_modules/engine.io/lib/server.js:280:21)
at /node_modules/engine.io/lib/server.js:217:12
at Server.checkRequest (/node_modules/socket.io/lib/index.js:69:51)
at Server.verify (/node_modules/engine.io/lib/server.js:151:17)
at Server.handleRequest (/node_modules/engine.io/lib/server.js:206:8)
at Server.<anonymous> (/node_modules/engine.io/lib/server.js:444:12)
at Server.<anonymous> (/node_modules/socket.io/lib/index.js:275:16)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:546:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)

它使Server.errors.BAD_REQUEST作为响应。 这是文件websocket.js

function WebSocket (req) { 
  Transport.call(this, req);  
  var self = this;  
  this.socket = req.websocket;
  this.socket.on('message', this.onData.bind(this));
  this.socket.once('close', this.onClose.bind(this));
  this.socket.on('error', this.onError.bind(this));
  this.socket.on('headers', onHeaders);
  this.writable = true;
  this.perMessageDeflate = null;
  function onHeaders (headers) {
    self.emit('headers', headers);
  }
}

如何查看哪些值未命中?

0 个答案:

没有答案