poco icon indicating copy to clipboard operation
poco copied to clipboard

Poco::Net::WebSocketImpl::_buffer was not used

Open back2now opened this issue 3 years ago • 3 comments

I wish Poco's websocket implementation takes a buffer to cache the next layer data. If so, I can safely call websocket::receiveFrame() with timeout succussively without corrupting the websocket stream, like this:

Poco::Net::Websocket ws;
ws.setReceiveTimeout(20ms);
std::vector<uint8_t> ws_msg;
while (1) {
    // ...
    ws.receiveFrame(ws_msg.data(), ws_msg.size());
    if (timeout) {
        continue;
    }
    // ...
    handleMsg();
}

back2now avatar May 11 '22 02:05 back2now

What's preventing you to do this:

ws.receiveFrame(&ws_msg[0], ws_msg.size());

aleks-f avatar Jun 22 '22 02:06 aleks-f

If a websocket frame is sent by two tcp packet with more than 20ms timeval, then the second call to ws.receiveFrame can not read correct message as the websocket stream is corrupted (just because the library didn't store the previous incomplete bytes). If this is by design, then websocket timeout is an unrecoverable exception.

back2now avatar Jun 28 '22 07:06 back2now

from what I'm reading, frames are either read completely, or else exception is thrown; but you can express your complaint in code (fix and corresponding test) and send pull request for review

aleks-f avatar Jun 28 '22 09:06 aleks-f

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] avatar Jun 29 '23 02:06 github-actions[bot]

This issue was closed because it has been inactive for 60 days since being marked as stale.

github-actions[bot] avatar Aug 29 '23 02:08 github-actions[bot]