UNET Transport Layer "Host ID is out of bound {0}"

I am playing around with a multi-host solution using Unet’s Transport Layer.
I can add hosts fine but when I try to connect a client I get the following Error:

host id out of bound id {0} max id should be greater 0 and less than {0}

Here is my connection Code:

    public void Start (){
		    Configure ();
		    Connect ();
	}

	public void Configure (){
		NetworkTransport.Init ();
		ConnectionConfig Config = new ConnectionConfig ();
		Config.AddChannel (QosType.ReliableFragmented);
		Topology = new HostTopology (Config, MaxConnections);
		if (Server)
		{
			HostID = NetworkTransport.AddHost (Topology, ServerPort, ServerIP);
			CreateHost ();
		}
	}

	public int FindPort (){
		if (OpenPorts.Count > 0){
			int Port = OpenPorts [0];
			OpenPorts.Remove (Port);
			return Port;
		}
		return 0;
	}

	public void CreateHost (){
		int Port = FindPort ();
		Host Host = (Host)Factory.Script.Create ("Host", "Host", Hosts);
		Host.HostID = NetworkTransport.AddHost (Topology, Port);
		Host.Port = Port;
	}

	public void Connect (){
		ConnectionID = NetworkTransport.Connect (0, ServerIP, ServerPort, 0, out Error);
	}

When I connect a new Host I can see that it is a assigned a HostID.
No matter which HostID I feed to the client connection I get the above error.
Am I missing something?

Thanks,
Sean

I have just recently started trying to learn about NetworkTransport, so I could be totally wrong about this, but your problem might stem from:

         if (Server)
         {
             HostID = NetworkTransport.AddHost (Topology, ServerPort, ServerIP);
             CreateHost (40.7500f, 111.8833f, 50f);
         }

As I understand it, even clients need to use NetworkTransport.AddHost. The “AddHost” name confused me at first, but it seems to be what is responsible for creating and registering sockets with NetworkTransport on both the server and the clients. Using “0” or any other hostId for the hostId parameter in:

     public void Connect (){
         ConnectionID = NetworkTransport.Connect (0, ServerIP, ServerPort, 0, out Error);
     }

will fail because AddHost was never called on the client (as far as I can tell), and as a result, the client’s NetworkTransport has no registered socket to use for the connection that corresponds with the “connectionId” you are giving it; in fact, it has no registered sockets at all.

you might want to add something like:

ConnectionConfig config = new ConnectionConfig();
reliableFragmentedChannel = config.AddChannel(QosType.ReliableFragmented);
HostTopology topology = new HostTopology(config, maxConnections);
clientSocket = NetworkTransport.AddHost(topology);

to an if (Client) part of your code somewhere and then use “clientSocket” as the hostId in the Connect method.

Hopefully I’m not misunderstanding everything.
Good luck!

try
{
NetworkTransport.RemoveHost(1);
NetworkTransport.RemoveHost(2);
NetworkTransport.RemoveHost(3);
NetworkTransport.RemoveHost(4);
}
catch
{
// Do nothing
}