Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6306] NamedPipe could not reconnect correctly when disconnected unexpectedly #6416

Merged
merged 5 commits into from
Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,22 @@ public async Task ConnectNamedPipeAsync(string pipeName, IBot bot, string appId,
var connectionId = Guid.NewGuid();
using (var scope = Logger.BeginScope(connectionId))
{
while (true)
{
#pragma warning disable CA2000 // Dispose objects before losing scope: StreamingRequestHandler is responsible for disposing StreamingConnection
var connection = new NamedPipeStreamingConnection(pipeName, Logger);
var connection = new NamedPipeStreamingConnection(pipeName, Logger);
#pragma warning restore CA2000 // Dispose objects before losing scope

using (var streamingActivityProcessor = new StreamingActivityProcessor(authenticationRequestResult, connection, this, bot))
{
// Start receiving activities on the named pipe
_streamingConnections.TryAdd(connectionId, streamingActivityProcessor);
Log.WebSocketConnectionStarted(Logger);
await streamingActivityProcessor.ListenAsync(CancellationToken.None).ConfigureAwait(false);
_streamingConnections.TryRemove(connectionId, out _);
Log.WebSocketConnectionCompleted(Logger);
using (var streamingActivityProcessor = new StreamingActivityProcessor(authenticationRequestResult, connection, this, bot))
{
// Start receiving activities on the named pipe
_streamingConnections.TryAdd(connectionId, streamingActivityProcessor);
Log.WebSocketConnectionStarted(Logger);
await streamingActivityProcessor.ListenAsync(CancellationToken.None).ConfigureAwait(false);
_streamingConnections.TryRemove(connectionId, out _);
Log.WebSocketConnectionCompleted(Logger);
Logger.LogWarning("Named pipe got disconnected. Reconnecting.");
}
}
}
}
Expand Down