Without seeing actual code, it's hard to diagnose an issue. Here's some general information that can help you understand the cause and potentially fix the issue.
short_read
doesn't happen if there's not enough buffer, it happens when the data received doesn't satisfy the expected amount.
Short reads are normal, see Streams, Short Reads and Short Writes.
So use the appropriate read
primitives to handle expected short reads:
Data may be read from or written to a connected TCP socket using the receive()
, async_receive()
, send()
or async_send()
member functions. However, as these could result in short writes or reads, an application will typically use the following operations instead: read()
, async_read()
, write()
and async_write()
.
The usual place where short reads crop up as an error condition is in SSL streams. OpenSSL generates the error condition¹ as stream_errors::stream_truncated
:
It can naturally occur when the peer doesn't negotiate a proper shutdown.
SSLv2 doesn't support a protocol-level shutdown, so an eof
will be passed through as eof
instead.
Relevant version history
Previous releases fixed bugs related to possible short reads:
Fixed an ssl::stream<> bug that may result in spurious 'short read' errors.
¹ For <v1.1 via SSL_R_SORT_READ
See also
Existing posts on this site, e.g. Short read error-Boost asio synchoronous https call