websocket: Handle eof and truncated stream
When doRead() fails, the code was checking the `closed` error code and
print the error log if it's other error codes.
In field we noticed that the error code could be `eof` or
`stream_truncated` if the websocket gets closed.
Add the above error codes as well so that it does not print error log on
closed websocket.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Id25f9750521d67643a125d7641eb73c75c328a85
diff --git a/http/websocket.hpp b/http/websocket.hpp
index be650ae..843aab3 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -4,6 +4,7 @@
#include "http_request.hpp"
#include <boost/asio/buffer.hpp>
+#include <boost/asio/ssl/error.hpp>
#include <boost/beast/core/multi_buffer.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/beast/websocket/ssl.hpp>
@@ -256,7 +257,9 @@
size_t bytesRead) {
if (ec)
{
- if (ec != boost::beast::websocket::error::closed)
+ if (ec != boost::beast::websocket::error::closed &&
+ ec != boost::asio::error::eof &&
+ ec != boost::asio::ssl::error::stream_truncated)
{
BMCWEB_LOG_ERROR("doRead error {}", ec);
}