diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 4d0a0b0c..11cb0af0 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -2485,10 +2485,15 @@ namespace WebSocketSharp /// public void CloseAsync (CloseStatusCode code) { - var msg = _readyState.CheckIfAvailable (true, true, false, false) ?? - CheckCloseParameters (code, null, _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, null, _client, out msg)) { _logger.Error (msg); error ("An error has occurred in closing the connection.", null);