1

According to websocket::stream::async_read documentation:

The asynchronous operation will continue until one of the following is true:

  • A complete message is received.
  • A close frame is received. In this case the error indicated by the function will be websocket::closed.
  • An error occurs on the stream.

This operation is implemented in terms of one or more calls to the next layer's async_read_some and async_write_some functions

But Boost.Asio documentation says:

When a short read or short write occurs the program must restart the operation, and continue to do so until the required number of bytes has been transferred. Boost.Asio provides generic functions that do this automatically: read(), async_read(), write() and async_write().

So it seems that instead of returning Short Read error, websocket::stream::async_read

should restart the operation , and continue to do so until the required number of bytes has been transferred

or report another error from the next layer. Can it be done this way?

I hope that it will allow to keep websocket operational longer which is essential in my case. Currently, I have to re-establish connection and it is a rather expensive process (due to another operations related to that) which I would like to avoid.

Or may be I should just ignore Short Read error and re-launch websocket::stream::async_read?

The error does not happen very often (once per several days), so it is difficult to test different solutions, but it happens always at critical moments, so it is painful.

zer0hedge
  • 449
  • 3
  • 12
  • See also https://github.com/boostorg/beast/issues/1123 and https://github.com/boostorg/beast/issues/38 (and https://github.com/cpp-netlib/cpp-netlib/issues/670) – sehe Feb 23 '21 at 16:52

0 Answers0