private async Task CloseWithReceiveErrorAndThrowAsync(
WebSocketCloseStatus closeStatus, WebSocketError error, CancellationToken cancellationToken, Exception innerException = null)
{
// Close the connection if it hasn't already been closed
if (!_sentCloseFrame)
{
await CloseOutputAsync(closeStatus, string.Empty, cancellationToken).ConfigureAwait(false);
}
// Dump our receive buffer; we're in a bad state to do any further processing
_receiveBufferCount = 0;
// Let the caller know we've failed
throw new WebSocketException(error, innerException);
}