Skip to content

Commit 1140c96

Browse files
bug: fixing indefinite wait
1 parent ffac796 commit 1140c96

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Nullinside.Api.Common/Extensions/WebSocketExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ public static class WebSocketExtensions {
3131
var data = new ArraySegment<byte>(new byte[1024]);
3232
response = await webSocket.ReceiveAsync(data, cancelToken);
3333
fullMessage.AddRange(data);
34-
} while (null == response.CloseStatus);
34+
} while (null == response.CloseStatus && !response.EndOfMessage);
3535

36-
return Encoding.ASCII.GetString(fullMessage.ToArray());
36+
// Remove the null character from the end of the string, this happens when the buffer is only partially filled.
37+
return Encoding.ASCII.GetString(fullMessage.ToArray()).TrimEnd('\0');
3738
}
3839
}

0 commit comments

Comments
 (0)