Suppress websocket aborted error log
When websocket is aborted under some situations like GUI console is
aborted earlier before websocket write is still waiting for completion,
it is currently logged as ERROR. However, it may not need to be an
error. This commit will change it as WARNING.
For example,
```
Oct 31 10:40:29 balco10 bmcwebd[1230]: [websocket_impl.hpp:305] Error in ws.async_write Operation canceled [system:125 at /usr/include/boost/beast/websocket/impl/stream_impl.hpp:355:13 in function 'bool boost::beast::websocket::stream< <template-parameter-1-1>, <anonymous> >::impl_type::check_stop_now(boost::beast::error_code&)']
```
Tested:
- While GUI page is loading pages (e.g. pcie topology), close
web-browser and check the bmcweb journal records.
Change-Id: I4b16c21d2784ec0b9774ab256f833bb38fc34a27
Signed-off-by: Myung Bae <myungbae@us.ibm.com>
diff --git a/http/websocket_impl.hpp b/http/websocket_impl.hpp
index eb68cda..72f31f1 100644
--- a/http/websocket_impl.hpp
+++ b/http/websocket_impl.hpp
@@ -251,6 +251,10 @@
{
BMCWEB_LOG_ERROR("doRead error {}", ec);
}
+ else if (ec == boost::asio::error::operation_aborted)
+ {
+ BMCWEB_LOG_WARNING("doRead operation is aborted: {}", ec);
+ }
if (closeHandler)
{
std::string reason{ws.reason().reason.c_str()};
@@ -277,16 +281,22 @@
{
doingWrite = false;
outBuffer.consume(bytesSent);
- if (ec == boost::beast::websocket::error::closed)
- {
- // Do nothing here. doRead handler will call the
- // closeHandler.
- close("Write error");
- return;
- }
if (ec)
{
- BMCWEB_LOG_ERROR("Error in ws.async_write {}", ec);
+ if (ec == boost::beast::websocket::error::closed)
+ {
+ // Do nothing here. doRead handler will call the
+ // closeHandler.
+ close("Write error");
+ }
+ else if (ec == boost::asio::error::operation_aborted)
+ {
+ BMCWEB_LOG_WARNING("doWrite operation is aborted: {}", ec);
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR("Error in ws.async_write {}", ec);
+ }
return;
}
doWrite();