Any sort of JSON deserializing stops code completely

private void Start()
        {
            ws = new WebSocket("ws://localhost:8080");
            ws.Connect();
            ws.OnMessage += (sender, e) =>
            {
                var data = e.Data;
                Debug.Log($"Packet received: {data}");
                object json = JsonConvert.DeserializeObject(data);
                Debug.Log("test");
                Debug.Log(json);
            };
        }

This is connecting to my Node.JS websocket server. Whenever I press space, the game sends a test packet to the server, and the server should respond with a packet like {"type":"setPos","pos":{"x":0,"y":0,"z":0}}, and Unity logs that. However, it never logs “test”. As a matter of fact, any code I put past the JsonConvert never runs. I also tried using JsonUtility, but that doesn’t work either. Please help!

Photographs of code are not a thing. If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: Using code tags properly

Everything you’re doing above will potentially block the main thread.

Networking in Unity is always best accomplished with UnityWebRequest(). Other options may not be fully supported.

Whenever you’re debugging networking, start here:

Networking, UnityWebRequest, WWW, Postman, curl, WebAPI, etc:

And setting up a proxy can be very helpful too, in order to compare traffic:

Problems with Unity “tiny lite” built-in JSON:

In general I highly suggest staying away from Unity’s JSON “tiny lite” package. It’s really not very capable at all and will silently fail on very common data structures, such as Dictionaries and Hashes and ALL properties.

Instead grab Newtonsoft JSON .NET off the asset store for free, or else install it from the Unity Package Manager (Window → Package Manager).

Also, always be sure to leverage sites like:

https://csharp2json.io