-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
int WebSocketImpl::receiveBytes(void* buffer, int length, int)
{
char header[MAX_HEADER_LENGTH];
int n = receiveNBytes(header, 2);
.........
.........
if (lengthByte + 2 + maskOffset < MAX_HEADER_LENGTH)
{
n = receiveNBytes(header + 2, lengthByte + maskOffset);
}
else
{
n = receiveNBytes(header + 2, MAX_HEADER_LENGTH - 2);
}
.........
.........
if (received < payloadLength)
{
n = receiveNBytes(reinterpret_cast<char*>(buffer) + received, payloadLength - received);
if (n <= 0) throw WebSocketException("Incomplete frame received", WebSocket::WS_ERR_INCOMPLETE_FRAME);
received += n;
}
.........
.........
return received;
}
As I am working on a very overloaded environment (+20 websocket connections, video&audio stream, file transmitions, ....), sometimes I am getting a "timeout exception" on the latest "receiveNBytes"(after read the websocket header) so I am afraid when we are trying to receive data again(by calling WebSocket::receiveFrame) "receiveBytes" function is interpreting the first part of the websocket payload as a websocket header and then my code is getting websocket exceptions("Insufficient buffer for payload size", "Incomplete header received").
I checked he timeout was throwed by the latest receiveNBytes including some trace on your code.
I have configured my websocket with a receiveTimeout = 250ms