From de04bb13a89a743235da3e30aa3fe7bb9506809e Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" <alexander.klimov@icinga.com> Date: Tue, 9 Apr 2019 13:53:41 +0200 Subject: [PATCH] JsonRpcConnection: reduce log spam on disconnect --- lib/remote/jsonrpcconnection.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index b850b7884..a7ec2cdff 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -18,7 +18,9 @@ #include <utility> #include <boost/asio/deadline_timer.hpp> #include <boost/asio/spawn.hpp> +#include <boost/asio/ssl/error.hpp> #include <boost/date_time/posix_time/posix_time_duration.hpp> +#include <boost/system/system_error.hpp> #include <boost/thread/once.hpp> using namespace icinga; @@ -61,7 +63,17 @@ void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc) message = JsonRpc::ReadMessage(m_Stream, yc, m_Endpoint ? -1 : 1024 * 1024); } catch (const std::exception& ex) { if (!m_ShuttingDown) { - Log(LogWarning, "JsonRpcConnection") + auto logLevelOnReadError (LogWarning); + + { + auto boostError (dynamic_cast<const boost::system::system_error*>(&ex)); + + if (boostError && boostError->code().category() == boost::asio::error::get_ssl_category()) { + logLevelOnReadError = LogNotice; + } + } + + Log(logLevelOnReadError, "JsonRpcConnection") << "Error while reading JSON-RPC message for identity '" << m_Identity << "': " << DiagnosticInformation(ex); }