public async Task Websocket_stream_should_work_when_client_closes() { await ConnectAsync(msg => Log.Info(msg)); await _connection.InvokeAsync(nameof(IServerSource.Send), "payload"); _fromClient.RequestNext().Should().BeOfType <Connected>(); _fromClient.RequestNext().Should().BeOfType <Received>(); // Client-initiated disconnect _connected = false; await _connection.StopAsync(); await _connection.DisposeAsync(); _connection = null; // Server should know _fromClient.RequestNext().Should().BeOfType <Disconnected>(); // Client reconnects to server var connection = _factory.CreateHubConnection(); connection.On <string>(nameof(IClientSink.Receive), msg => Log.Info(msg)); await connection.StartAsync(); // Server should see new connection _fromClient.RequestNext().Should().BeOfType <Connected>(); // Send new message await connection.InvokeAsync(nameof(IServerSource.Send), "payload"); _fromClient.RequestNext().Should().BeOfType <Received>(); }