From 1140c96f82f4a0d985f6efb8a57540a48ae90421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=E2=96=88=E2=96=88=E2=96=88=E2=96=88=E2=96=88?= Date: Sun, 20 Jul 2025 17:52:52 -0400 Subject: [PATCH] bug: fixing indefinite wait --- src/Nullinside.Api.Common/Extensions/WebSocketExtensions.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Nullinside.Api.Common/Extensions/WebSocketExtensions.cs b/src/Nullinside.Api.Common/Extensions/WebSocketExtensions.cs index a77a32b..6811d86 100644 --- a/src/Nullinside.Api.Common/Extensions/WebSocketExtensions.cs +++ b/src/Nullinside.Api.Common/Extensions/WebSocketExtensions.cs @@ -31,8 +31,9 @@ public static class WebSocketExtensions { var data = new ArraySegment(new byte[1024]); response = await webSocket.ReceiveAsync(data, cancelToken); fullMessage.AddRange(data); - } while (null == response.CloseStatus); + } while (null == response.CloseStatus && !response.EndOfMessage); - return Encoding.ASCII.GetString(fullMessage.ToArray()); + // Remove the null character from the end of the string, this happens when the buffer is only partially filled. + return Encoding.ASCII.GetString(fullMessage.ToArray()).TrimEnd('\0'); } } \ No newline at end of file