internal async Task DisconnectWebsocket(
     WebsocketSenderHandler sender)
 {
     try
     {
         await sender.SendCloseHandshakeAsync(StatusCodes.GoingAway)
         .ToObservable()
         .Timeout(TimeSpan.FromSeconds(5));
     }
     catch (Exception ex)
     {
         throw new WebsocketClientLiteException("Unable to disconnect gracefully", ex);
     }
     finally
     {
         _connectionStatusAction(ConnectionStatus.Disconnected, null);
     }
 }
        internal async Task DisconnectWebsocketServer()
        {
            _observerConnectionStatus.OnNext(ConnectionStatus.Disconnecting);

            try
            {
                await _websocketSenderHandler.SendCloseHandshakeAsync(TcpStream, StatusCodes.GoingAway).ToObservable().Timeout(TimeSpan.FromSeconds(5));
            }
            catch (Exception ex)
            {
                throw new WebsocketClientLiteException("Unable to disconnect.", ex);
            }

            try
            {
                await _websocketParserHandler.DataReceiveStateObservable.Timeout(TimeSpan.FromSeconds(10));
            }
            catch (InvalidOperationException)
            {
                Debug.WriteLine("Ignore. Already disconnected.");
            }
            catch (TimeoutException ex)
            {
                throw new WebsocketClientLiteException("Disconnect timed out. Unable to disconnect gracefully.", ex);
            }
            catch (Exception ex)
            {
                throw new WebsocketClientLiteException("Unable to disconnect gracefully.", ex);
            }
            finally
            {
                _observerConnectionStatus.OnNext(ConnectionStatus.Disconnected);
                _observerConnectionStatus.OnCompleted();
                _observerMessage.OnCompleted();
            }
        }