[wpinet] WebSocket: Improve disconnect reason reporting (#6262)

Add "remote close:" to messages coming from the remote end.
Previously it was impossible to tell if the error was on the local side
or communicated by the remote side.
This commit is contained in:
Peter Johnson
2024-01-19 23:13:38 -08:00
committed by GitHub
parent 0e5eb3f35c
commit 24a24c9051
2 changed files with 5 additions and 4 deletions

View File

@@ -638,7 +638,7 @@ void WebSocket::HandleIncoming(uv::Buffer& buf, size_t size) {
if (m_state != CLOSING) {
SendClose(code, reason);
}
SetClosed(code, reason);
SetClosed(code, fmt::format("remote close: {}", reason));
// If we're the server, shutdown the connection.
if (m_server) {
Shutdown();
@@ -675,7 +675,8 @@ void WebSocket::HandleIncoming(uv::Buffer& buf, size_t size) {
pong(m_controlPayload);
break;
default:
return Fail(1002, "invalid message opcode");
return Fail(1002, fmt::format("invalid message opcode {}",
static_cast<unsigned int>(opcode)));
}
// Prepare for next message