Skip to content

Commit

Permalink
Close socket when connecting and authentication fails
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Jun 23, 2024
1 parent 09ed7d1 commit e927bc3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CryptoExchange.Net/Clients/SocketApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ protected virtual async Task<CallResult> ConnectIfNeededAsync(SocketConnection s
if (!authenticated || socket.Authenticated)
return new CallResult(null);

return await AuthenticateSocketAsync(socket).ConfigureAwait(false);
var result = await AuthenticateSocketAsync(socket).ConfigureAwait(false);
if (!result)
await socket.CloseAsync().ConfigureAwait(false);

return result;
}

/// <summary>
Expand Down

0 comments on commit e927bc3

Please sign in to comment.