You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let me explain what happens.
A server and a client are created, the client sends 3 packets of 10mb encoded with msgpack. Each packet has header and data (where data contains type and payload.
The header contains 4 bytes so on the server side we know the contentLength.
When the client receives data, he first reads 4 bytes for the contentLength and then uses the contentLength to alloc a Buffer of that size.
On the first read it returns the Buffer with all data (of the correct size and correct contents) but the read bytes are lower than the Buffer size and you have to process the rest of the bytes in order to get to the next packet, even though the rest of the bytes are invalid (or parts of the original Buffer)
Im my case, it fills the whole buffer with the correct data, but the read variable says it only read part of it. Usually below 64kb.
I figured it out, i don't know why on the first read it the buffer is with complete data, but if i slice the buffer with the bytes read and concat when the total sum of the read bytes is equal to the contentLength, everything works correctly.
Let me explain what happens.
A server and a client are created, the client sends 3 packets of 10mb encoded with msgpack. Each packet has
header
anddata
(where data containstype
andpayload
.The header contains 4 bytes so on the server side we know the
contentLength
.When the client receives data, he first reads 4 bytes for the contentLength and then uses the
contentLength
to alloc a Buffer of that size.On the first
read
it returns the Buffer with all data (of the correct size and correct contents) but theread bytes
are lower than the Buffer size and you have to process the rest of the bytes in order to get to the next packet, even though the rest of the bytes are invalid (or parts of the original Buffer)Output:
Am i doing something wrong, or is this a bug?
The text was updated successfully, but these errors were encountered: