Description
Is your feature request related to a problem? Please describe.
With transport polling, the number of packets in the write buffer can grow very large, to the point that the next request becomes larger than the maxHttpBufferSize
setting on the server. When this happens, the request fails and the client gets disconnected.
Describe the solution you'd like
It would be useful to have a way to limit the number of packets sent in a single request to the server. This could be a new option to set the maximum number of packets to send in a single request. Eg.
const socket = io(serverUrl, { maxPacketsPerRequest: 200 });
At the moment of sending the request, the client takes from the buffer and send a number of packets up to maxPacketsPerRequest
; if the buffer contains more packets than this value, the remaining ones are left in the buffer and sent at the next cycle.
Alternatively, the limit could be based on the size of the request: the client takes packets from the buffer up the point where the resulting request reaches a maximum payload size. The limit could then be set to the same value as maxHttpBufferSize
on the server, ensuring that the client never sends too large a request. This is probably harder to build though, because you need to predict the serialised size of every packet.