Open qknight opened 1 year ago
Using msg->type == ix::WebSocketMessageType::Error and std::string reason = msg->errorInfo.reason adds an unwanted newline.
See my log
2023-05-05 14:17:51 2023-05-05 12:17:51.300122|INFO |AppServer | |Websocket connection to ws://example.com/ws closed 2023-05-05 14:17:51 2023-05-05 12:17:51.305053|ERROR |AppServer | |Connection error: Expecting status 101 (Switching Protocol), got 502 status connecting to ws://example.com/ws, HTTP Status line: HTTP/1.1 502 Bad Gateway 2023-05-05 14:17:51 2023-05-05 14:18:21 2023-05-05 12:18:21.427484|ERROR |AppServer | |Connection error: Expecting status 101 (Switching Protocol), got 504 status connecting to ws://example.com/ws, HTTP Status line: HTTP/1.1 504 Gateway Timeout 2023-05-05 14:18:21 2023-05-05 14:18:21 2023-05-05 12:18:21.630300|ERROR |AppServer | |Connection error: Expecting status 101 (Switching Protocol), got 404 status connecting to ws://example.com/ws, HTTP Status line: HTTP/1.1 404 Not Found 2023-05-05 14:18:21 2023-05-05 14:18:22 2023-05-05 12:18:22.032787|ERROR |AppServer | |Connection error: Expecting status 101 (Switching Protocol), got 404 status connecting to ws://example.com/ws, HTTP Status line: HTTP/1.1 404 Not Found 2023-05-05 14:18:22 2023-05-05 14:18:22 2023-05-05 12:18:22.836496|INFO |AppServer | |Websocket connection to ws://example.com/ws established
} else if (msg->type == ix::WebSocketMessageType::Error) { std::string reason = msg->errorInfo.reason; reason.erase(std::remove(reason.begin(), reason.end(), '\n'), reason.cend()); LOGL(<< "Connection error: " << reason, LogLevel_ERROR); }
The newline is added in the variable line at:
std::stringstream ss; ss << "Expecting status 101 (Switching Protocol), got " << status << " status connecting to " << url << ", HTTP Status line: " << line;
https://github.com/machinezone/IXWebSocket/blob/dfa10df5ae89697d5dad56e1845aee64d2334d70/ixwebsocket/IXWebSocketHandshake.cpp#L194
description
Using msg->type == ix::WebSocketMessageType::Error and std::string reason = msg->errorInfo.reason adds an unwanted newline.
See my log
fix (hack)
real fix
The newline is added in the variable line at:
https://github.com/machinezone/IXWebSocket/blob/dfa10df5ae89697d5dad56e1845aee64d2334d70/ixwebsocket/IXWebSocketHandshake.cpp#L194