Skip to content

Commit a349ab2

Browse files
Do no more cerr closing messages by default
1 parent bd4e72d commit a349ab2

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/etp/AbstractSession.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ void AbstractSession::on_read(boost::system::error_code ec, std::size_t bytes_tr
4848

4949
if (ec == websocket::error::closed) {
5050
// This indicates that the web socket (and consequently etp) session was closed
51-
std::cerr << "The other endpoint closed the web socket (and consequently etp) connection" << std::endl;
51+
if (etpSessionClosed) {
52+
fesapi_log("The other endpoint closed the web socket (and consequently etp) connection in a graceful way.");
53+
}
54+
else {
55+
std::cerr << "The other endpoint closed the web socket(and consequently etp) connection in a graceful way." << std::endl;
56+
}
5257
}
5358
#if BOOST_VERSION > 106900
5459
else if (ec == boost::beast::error::timeout) {
@@ -57,13 +62,15 @@ void AbstractSession::on_read(boost::system::error_code ec, std::size_t bytes_tr
5762
}
5863
#endif
5964
else {
60-
// This indicates an unexpected error
61-
std::cerr << "on_read : error code number " << ec.value() << std::endl;
62-
std::cerr << "on_read : error message " << ec.message() << std::endl;
63-
std::cerr << "on_read : error category " << ec.category().name() << std::endl;
64-
// This error may be a common one to ignore in case of SSL short read : https://github.com/boostorg/beast/issues/824
6565
if (etpSessionClosed) {
66-
std::cerr << "It looks that the other endpoint has closed the websocket session in a non graceful way" << std::endl;
66+
// This error may be a common one to ignore in case of SSL short read : https://github.com/boostorg/beast/issues/824
67+
fesapi_log("It looks that the other endpoint has closed the websocket session in a non graceful way.");
68+
}
69+
else {
70+
// This indicates an unexpected error
71+
std::cerr << "on_read : error code number " << ec.value() << std::endl;
72+
std::cerr << "on_read : error message " << ec.message() << std::endl;
73+
std::cerr << "on_read : error category " << ec.category().name() << std::endl;
6774
}
6875
}
6976

@@ -149,7 +156,7 @@ void AbstractSession::on_read(boost::system::error_code ec, std::size_t bytes_tr
149156
normalProtocolHandlerIt->second->decodeMessageBody(receivedMh, d);
150157
}
151158
else {
152-
std::cerr << "Received a message with id " << receivedMh.messageId << " for which non protocol handlers is associated. Protocol " << receivedMhProtocol << std::endl;
159+
std::cerr << "Received a message with id " << receivedMh.messageId << " for which no protocol handler is associated. Protocol " << receivedMhProtocol << std::endl;
153160
send(ETP_NS::EtpHelpers::buildSingleMessageProtocolException(4, "The agent does not support the protocol " + std::to_string(receivedMhProtocol) + " identified in a message header."), receivedMh.messageId, 0x02);
154161
}
155162
}

0 commit comments

Comments
 (0)