diff --git a/ChromiumHtmlToPdfLib/Connection.cs b/ChromiumHtmlToPdfLib/Connection.cs
index fc3c0b4..e90ffea 100644
--- a/ChromiumHtmlToPdfLib/Connection.cs
+++ b/ChromiumHtmlToPdfLib/Connection.cs
@@ -165,7 +165,7 @@ private static async Task ReceiveLoop(object? stateData)
{
// Ignore
}
- catch (WebSocketException wsex) when (wsex.Message == "The remote party closed the WebSocket connection without completing the close handshake.")
+ catch (WebSocketException webSocketException) when (webSocketException.Message == "The remote party closed the WebSocket connection without completing the close handshake.")
{
// Ignore
}
@@ -265,8 +265,8 @@ internal async Task SendForResponseAsync(Message message, CancellationTo
await _webSocket.SendAsync(MessageToBytes(message), WebSocketMessageType.Text, true, cancellationToken).ConfigureAwait(false);
- var response = tcs.Task.Result;
- return response;
+ tcs.Task.Wait(cancellationToken);
+ return cancellationToken.IsCancellationRequested ? tcs.Task.Result : string.Empty;
}
catch (Exception exception)
{