IXWebSocket
IXWebSocket copied to clipboard
TLS chunking on Windows/mbedTLS crashes server
The issue #323 still persists, the solution at https://github.com/machinezone/IXWebSocket/issues/323#issuecomment-981804457 is still the way to go.
I believe the problem is that your os cannot send the data fast enough, so the TCP flow control kick and the socket isn't marked as 'writable' anymore. In theory the code should detect that, and try to flush the send buffer later (in the background thread iirc).
I think you're going to have to debug this and maybe propose a PR to improve things ; I don't really have the time to do this now unfortunately.
Well, the break
in the loop logic seems wrong either way.
No background thread will be able to clean this up before the next chunk goes out.
Keep in mind this breaks somewhere at 5/20 chunks.
I don't have a large enough insight into the project to attempt to fix this properly, all I can say is that my small change works for me:
if (ret < 0 && Socket::isWaitNeeded())
{
std::this_thread::sleep_for(std::chrono::milliseconds(25));
continue;
}
I am happy to help/test if someone else has a better understanding of the mentioned code.
You can try to disable the zlib compression that might help.
I already compile with zlib disabled.
You could try to change the socket send buffer size to something bigger, that will mean patching ixwebsocket. I'm not really sure it will change much but it's worth a try.
https://stackoverflow.com/questions/28785626/what-is-the-size-of-a-socket-send-buffer-in-windows
You would do that inside https://github.com/machinezone/IXWebSocket/blob/e12a6ddbdddc7464421a55e79292f6393d6f4d63/ixwebsocket/IXSocketConnect.cpp#L132
setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char*)&send_buffer, send_buffer_sizeof);