Dispose WebSocket if StartAsync fails (#3311)

This commit is contained in:
BrennanConroy 2018-11-16 19:54:24 -08:00 committed by GitHub
parent 3db604d9d2
commit 4cbabea501
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -119,7 +119,15 @@ namespace Microsoft.AspNetCore.Http.Connections.Client.Internal
Log.StartTransport(_logger, transferFormat, resolvedUrl);
await _webSocket.ConnectAsync(resolvedUrl, CancellationToken.None);
try
{
await _webSocket.ConnectAsync(resolvedUrl, CancellationToken.None);
}
catch
{
_webSocket.Dispose();
throw;
}
Log.StartedTransport(_logger);