From e6e0637f572408867d016f20dc4c8f4047f97ff4 Mon Sep 17 00:00:00 2001 From: David Bottiau Date: Fri, 31 May 2024 13:01:54 +0200 Subject: [PATCH] Use Buffer to extract TextMessage from Stream --- src/Websocket.Client/WebsocketClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Websocket.Client/WebsocketClient.cs b/src/Websocket.Client/WebsocketClient.cs index 8b4c898..a7b6842 100644 --- a/src/Websocket.Client/WebsocketClient.cs +++ b/src/Websocket.Client/WebsocketClient.cs @@ -476,7 +476,7 @@ private async Task Listen(WebSocket client, CancellationToken token) if (result.MessageType == WebSocketMessageType.Text && IsTextMessageConversionEnabled) { - var data = GetEncoding().GetString(ms.ToArray()); + var data = GetEncoding().GetString(ms.GetBuffer(), 0, (int)ms.Length); message = ResponseMessage.TextMessage(data); } else if (result.MessageType == WebSocketMessageType.Close)