diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 2b3b205e4..79d1986ca 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -182,7 +182,6 @@ static inline void shutdownLimitReached(WebSocket& ws) { const std::string error = Poco::format(PAYLOAD_UNAVALABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS); - const std::string close = Poco::format(SERVICE_UNAVALABLE_LIMIT_REACHED, static_cast(WebSocket::WS_POLICY_VIOLATION)); /* loleaflet sends loolclient, load and partrectangles message immediately after web socket handshake, so closing web socket fails loading page in @@ -204,7 +203,7 @@ void shutdownLimitReached(WebSocket& ws) if (--retries == 4) { ws.sendFrame(error.data(), error.size()); - ws.shutdown(WebSocket::WS_POLICY_VIOLATION, close); + ws.shutdown(WebSocket::WS_POLICY_VIOLATION, ""); } } while (retries > 0 && (flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE); @@ -212,7 +211,7 @@ void shutdownLimitReached(WebSocket& ws) catch (Exception&) { ws.sendFrame(error.data(), error.size()); - ws.shutdown(WebSocket::WS_POLICY_VIOLATION, close); + ws.shutdown(WebSocket::WS_POLICY_VIOLATION, ""); } } @@ -897,8 +896,8 @@ private: // something wrong, with internal exceptions Log::trace("Abnormal close handshake."); session->closeFrame(); - ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, SERVICE_UNAVALABLE_INTERNAL_ERROR); - session->shutdownPeer(WebSocket::WS_ENDPOINT_GOING_AWAY, SERVICE_UNAVALABLE_INTERNAL_ERROR); + ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); + session->shutdownPeer(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); } } @@ -1050,7 +1049,7 @@ public: const std::string msg = std::string("error: ") + exc.what(); ws->sendFrame(msg.data(), msg.size()); // abnormal close frame handshake - ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, msg); + ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); } catch (const std::exception& exc2) { @@ -1275,8 +1274,8 @@ public: // something wrong, with internal exceptions Log::trace("Abnormal close handshake."); session->closeFrame(); - ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, SERVICE_UNAVALABLE_INTERNAL_ERROR); - session->shutdownPeer(WebSocket::WS_ENDPOINT_GOING_AWAY, SERVICE_UNAVALABLE_INTERNAL_ERROR); + ws->shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); + session->shutdownPeer(WebSocket::WS_ENDPOINT_GOING_AWAY, ""); } } catch (const Exception& exc) diff --git a/loolwsd/UserMessages.hpp b/loolwsd/UserMessages.hpp index 36e6ad3b1..7883fc0ef 100644 --- a/loolwsd/UserMessages.hpp +++ b/loolwsd/UserMessages.hpp @@ -13,9 +13,7 @@ #define INCLUDED_USERMESSAGES_HPP //NOTE: For whatever reason Poco seems to trim the first character. - constexpr auto SERVICE_UNAVALABLE_INTERNAL_ERROR = " Service is unavailable. Please try again later and report to your administrator if the issue persists."; -constexpr auto SERVICE_UNAVALABLE_LIMIT_REACHED = "error: cmd=socket kind=close code=%d"; constexpr auto PAYLOAD_UNAVALABLE_LIMIT_REACHED = "error: cmd=socket kind=limitreached params=%d,%d"; #endif diff --git a/loolwsd/test/httpwserror.cpp b/loolwsd/test/httpwserror.cpp index 8e7769dce..509046cd5 100644 --- a/loolwsd/test/httpwserror.cpp +++ b/loolwsd/test/httpwserror.cpp @@ -103,7 +103,6 @@ void HTTPWSError::testMaxDocuments() sendTextFrame(socket, "partpagerectangles "); statusCode = getErrorCode(socket, message); CPPUNIT_ASSERT_EQUAL(static_cast(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode); - CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("error: cmd=socket kind=close") != std::string::npos); } catch (const Poco::Exception& exc) { @@ -144,7 +143,6 @@ void HTTPWSError::testMaxConnections() sendTextFrame(socketN, "partpagerectangles "); statusCode = getErrorCode(*socketN, message); CPPUNIT_ASSERT_EQUAL(static_cast(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode); - CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("error: cmd=socket kind=close") != std::string::npos); } catch (const Poco::Exception& exc) {