Guest API WebSocket connection drops immediately after sending 'connect' message in C#

We are trying to build a custom chat UI for our agent desktop wrapper using the Guest API instead of the standard widget. The goal is to have full control over the UI elements, but we are running into issues with the WebSocket handshake logic. We have the endpoint from the POST /api/v2/conversations/webchat/guests call, which returns the webSocketUrl and sessionId.

Here is how we are handling the connection in C# using System.Net.WebSockets:

var client = new System.Net.WebSockets.ClientWebSocket();
await client.ConnectAsync(new Uri(webSocketUrl), CancellationToken.None);

// Send the connect message
var connectMsg = new { 
 type = "connect", 
 sessionId = sessionId, 
 version = "1.0" 
};
var json = JsonSerializer.Serialize(connectMsg);
var buffer = Encoding.UTF8.GetBytes(json);
await client.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Text, true, CancellationToken.None);

The connection opens successfully, but as soon as we send the connect message, the server sends back a close frame with code 1000. We are not receiving any error payload, just the close event. We have verified that the sessionId matches the one returned from the REST API call. We also tried adding the x-genesys-session-id header to the WebSocket upgrade request, but that didn’t change the behavior.

Is there a specific sequence of messages we need to send after connect? The documentation is sparse on the exact WebSocket protocol flow. We are using .NET 6 and the latest version of the SDK for the initial REST calls. Any insights on why the server is closing the connection immediately?