Closed Joannis closed 7 years ago
Damn, can you please send a PR with a failing test showing this? Thanks so much for reporting it!
Hmm isn't that a general issue of receiving data that evenly divides into your chunk size? If we're receiving 1024, for instance, in the first loop, we'll receive newData.length == 512, we'll append it to buffer, and check: newData.count (512) < chunkSize (512) needs to fail, otherwise we wouldn't read the rest.
The real issue is that recv
doesn't return 0 bytes when there's no more data, instead of blocking.
Nothing specifically. But if you take a custom TCP server, make a TCP client with Socks, let the server send 512 bytes and keep the socket open. The client will never receive the 512 bytes. Same goes for messages of 1024, 2048 bytes etc
A way to fix this would be to find out how to ensure recv
returns 0 bytes when there's no data left instead of blocking.
Since nobody picked this up yet I'll propose my (semi-)solution. Increase the default recv chunk size to UInt16.max
or UInt16.max - 1
.
Here at the line
if newData.count < chunkSize
every user will get a timeout when the last chunk received (newData
) has a count of 512 bytes. This has been haunting us for days until we realised the socket library might be at fault.