socket.on('connection' … event never fired nodejs + express + socket.io

前端 未结 3 723
遥遥无期
遥遥无期 2020-12-29 09:15

Problem socket.io NOT working

Details

  • Generated a project with express [folder]; cd [folder]; npm install;
3条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 09:42

    The following did a trick for me with: socket.io-client: "^0.9.16"

    io.connect("http://localhost:4000", {'force new connection': true});
    

    Now 'connect' event fires consistently and there is no re-use.

    I figured out this option by examining socket.io-client/lib/io.js line: 192 Since I can't even find this io.js file in github, I think there is refactoring in future releases, and this option might not work.

    At least this might be helpful to somebody who will take this temporary work around.

提交回复
热议问题