C# Unity - Web Socket Server - Reading incoming messages from clients on new thread.,Unity C#. Creating a network stream within a new thread isn't looping?

SO this is my problem. hoping someone can shed some light.

I have created a Web TCP server script. When a new connection comes in, it creates a new object ‘NetworkClientInfo’.
The NetworkClientInfo has a constructor that will create a new thread for my ‘ListenForMessages’ method.

So when a new client connects, it creates this object and passes in the TcpClient object, which then creates a thread, which then forever is supposed to listen for messages from that client. Though its just freezing when I get to NetworkStream.GetStream.

See this code:

When running this, I would expect the log to show “Before, After” and then to spam “Length Before” every second. Yet instead it is just giving me “Before” and then nothing else happens. If i remove the NetworkStream = client.GetSteram. It runs as intended. Equally if i call the method directly from the main thread (instead of creating a new thread) it runs as expected.

Anyone know what is going on here? Here is my Incoming connections method as well.

Just to add, I said if you call it directly from the main thread. It runs fine. Technically its not called from the Main thread as the ‘Listen for connections’ is also running on its own thread. Though I shouldn’t think this detail will matter? Its just the NetworkStream that seems to be messing it up.