Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by STBarnard · Nov 28, 2015 at 09:28 AM · c#networkingtransport

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Oct 08, 2018 at 11:31 PM 0
Share

NOTE

For late 2018 I found one of the problems, recently introduced by Unity.

https://forum.unity.com/threads/networkmanager-error-server-client-disconnect-error-1.439245/#post-3754939

Note the aside in RED near the middle. That's the secret

"(Important aside. For late 2018 you must stop your client discovery above in OnClientConnect, directly after the call to the base. You actually can NOT do it in your discovery client.)"

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Ahndrakhul · Nov 29, 2015 at 10:13 AM

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!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image STBarnard · Nov 29, 2015 at 06:13 PM 1
Share

This was absolutely the answer. You have to call "AddHost" on even the clients. Thanks so much, I am up and running Sending all kinds of transmissions! :D

They should change the name of that call to "OpenSocket", that would get people up and running I think.

Thanks again, Sean

avatar image
0

Answer by ShantuApps · Feb 11, 2018 at 03:48 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Unity's LLAPI for Raspberry Pi Server? 0 Answers

Multiple Cars not working 1 Answer

How can I read data sent using the Transport API with python server 1 Answer

NetworkManager.OnServerDisconnect not being called 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges