socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

[bug] Cannot read property 'indexOf' of undefined in engine.io/lib/server.js:132:24

Open SteveCruise opened this issue 9 years ago • 5 comments

Current behaviour

[2017-04-20 11:01:35.003] [ERROR] console - Caught exception: TypeError: Cannot read property 'indexOf' of undefined
    at Server.verify (/root/WebstormProjects/treasures/game-server/node_modules/engine.io/lib/server.js:132:24)
    at Server.handleRequest (/root/WebstormProjects/treasures/game-server/node_modules/engine.io/lib/server.js:205:8)
    at Server.<anonymous> (/root/WebstormProjects/treasures/game-server/node_modules/engine.io/lib/server.js:432:12)
    at Server.<anonymous> (/root/WebstormProjects/treasures/game-server/node_modules/socket.io/lib/index.js:275:16)
    at emitTwo (events.js:106:13)
    at Server.emit (events.js:192:7)
    at parserOnIncoming (_http_server.js:565:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)

when I use socket.io-client to connect to socket.io server. The server side print error.

Environment

  • OS: ubuntu 16.04
  • browser: server side bug
  • socket.io version: 1.7.2

SteveCruise avatar Apr 20 '17 03:04 SteveCruise

Could you please provide more details? How are you initializing your server (especially the transports options here)?

darrachequesne avatar Apr 20 '17 10:04 darrachequesne

@darrachequesne Thank you very much, I know the answer. It's because the open source server side(called pomelo) doesn't init the transports. Thank you very very much.

SteveCruise avatar Apr 21 '17 01:04 SteveCruise

@SteveCruise Hi, please, would you be able to tell me how you fixed this? :)

sara-h-chen avatar Oct 31 '17 15:10 sara-h-chen

while initializing pomelo app like on server

var app = pomelo.createApp(); app.set('name', 'demo');

app.configure('production|development', function(){ });

add connector config with transports

app.set('connectorConfig',
{
  connector : pomelo.connectors.sioconnector,
  // 'websocket', 'polling-xhr', 'polling-jsonp', 'polling'
  transports : ['websocket', 'polling'],
  heartbeats : true,
  closeTimeout : 70 * 1000,
  heartbeatTimeout : 60 * 1000,
  heartbeatInterval : 35 * 1000
});

Vvkgaming avatar Apr 30 '20 08:04 Vvkgaming

Hey guys, Im trying to install Node-poker-stack-master and I had the same problem. Can anyone give me directions how to solve that "TypeError: Cannot read property 'indexOf' of undefined" ?

@SteveCruise If you solved it I would much appreciate explanation. Tnx.

xprv17 avatar Feb 10 '22 10:02 xprv17