Trouble with NetworkTransport LLAPI Client/Server implementation


I have been digging through the Unity LLAPI trying to combine the various bits provided throughout the very sparse documentation as well as blog posts to get a basic Client/Server setup going, but I am running into a pretty frustrating error (I am able to connect, but when I try sending a message I am told I have a WrongConnection).

Here is the code for my client and server:

I explain the situation at the bottom of that gist, but the tl;dr is:

  1. I have 2 instances of Unity running on the same network (on different machines), one running the Server and one running the Client. The Client is pointed to the internal ip of the Server.
  2. When I call the Connect method on the Client, I see a resulting connection message on both sides.
  3. Afterwards, I call SendSocketMessage on the Client, and I get an error telling me that I have a WrongConnection.
  4. After closing the Client I see the resulting disconnection message on the Server.

The documentation leaves me a bit perplexed, so I am not entirely certain what I am doing wrong.

Any help is greatly appreciated!

I had the same problem not too long ago. The Client needs this code as well as the server, else the client doesn’t know it’s connected.

 switch (networkEvent)
         case NetworkEventType.ConnectEvent: