diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7df01a7b..55b6ce0e 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2394,10 +2394,15 @@ namespace WebSocketSharp /// public void Close (CloseStatusCode code, string reason) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, reason, _client); + string msg; + if (!checkIfAvailable (true, true, false, false, out msg)) { + _logger.Error (msg); + error ("An error has occurred in closing the connection.", null); - if (msg != null) { + return; + } + + if (!CheckParametersForClose (code, reason, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null);