Socket.io - failed: Connection closed before receiving a handshake response

前端 未结 5 1337
庸人自扰
庸人自扰 2021-01-01 15:24

Socket.io for NodeJS doesn\'t seem to work as a websocket server

For some reason, socket.io ALWAYS fallback to the long polling and if I force the w

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-01 16:14

    It worked for me!

    restUrl = 'http://x.x.x.x:5555;
    
    socket = io(this.restUrl, {
            transports: ["websocket"],
            upgrade: true,
            upgradeTimeout: 6000000,
            pingTimeout: 15000000000,
            pingInterval: 1500000000,
            maxHttpBufferSize: 10000000,
          });
    
    connect() {
            if (this.socket.connected == false) {
                var temp = this;
                this.socket.connect();
                this.socket.on('event', function (data) {
                    temp.socketData.next(data);
                });
            }
        }
    

提交回复
热议问题