0

I'm using socket.io v4.0.0 and socket.io-client v4.0.0 and I want to broadcast an image in base64 through the socket.io server.
Server side initialization code

    this.io = new Server(httpServer, {
        cors: {
          origin: '*',
          credentials: true
        }
    });

    this.io.on('connection', (socket) => {
        this.onConnection(socket);
    });

Whenever I send an image in base64 with socket.emit('broadcastImage'. base64ImageData) I'm having a Transport close error and the client disconnect. I printed the data in the developper console and it says the data base64 is 1.7 Mb. Is there something with the new version of socket.io that limits the size of the data that can be sent or is it a timeout issue ? I tried to set a big pingtimeout and pinginterval value on the server side without success.

Edit: After several tests, it seems that below 1Mb it's fine, whenever the data is above 1Mb I have the Transport close error

Observablerxjs
  • 692
  • 6
  • 22

1 Answers1

1

Solved! It was due to the fact the in the migration from 2.x to 3.x the maxHttpBufferSize was reduced from 100Mb to 1Mb. Setting this attribute back to 100Mb in the server initializtion fixed this for me:

     this.io = new Server(httpServer, {
            cors: {
              origin: '*',
              credentials: true
            },
            maxHttpBufferSize: 1e8
        });
    }
Observablerxjs
  • 692
  • 6
  • 22