0

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

如何检查错过了哪些值?

4

0 回答 0