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
0
Question by HiwackVDP · Jul 26, 2018 at 02:08 PM · networkingerror messageissue

Unet error code : unity host id out of bound id -1 max id should be greater 0 and less than 2

Tried to run on 2018.2.0f2 and 2017.2.0f3 That's now 3 days I'm trying to get rid of this error. I've tried to allow unity in my firewalls, uninstall and install back again unity, to see if i've modified something wrong. But I can't even see what the issue is. Here is the complete error :


unity host id out of bound id {-1} max id should be greater {0} and less than {2} UnityEngine.Networking.NetworkDiscovery:Update()


and here is the code I us for the NetworkManager and the NetworkDiscovery :

NetworkManager :

     public bool runAsServer = true;
 
     private CustomNetworkDiscovery netDiscovery;
 
     void Start () {
 
         netDiscovery = GetComponent<CustomNetworkDiscovery>();
         netDiscovery.Initialize();
 
         if (runAsServer) {
             SetupServer();
         } else {
             SetupClient();
         }
     }
 
     void netDiscovery_OnReceivedNetworkBroadcast(string fromAddress, string data)
     {
         Debug.Log("Received fromAddress:" + fromAddress);
         Debug.Log("Received data:" + data);
 
         networkAddress = fromAddress;
         StartClient();
         netDiscovery.StopBroadcast();
     }
 
     void SetupServer(){
         
         networkAddress = "localhost";
         StartHost();
 
         netDiscovery.StartAsServer();
 
     }
 
     void SetupClient(){
 
         netDiscovery.OnReceivedNetworkBroadcast += netDiscovery_OnReceivedNetworkBroadcast;
         netDiscovery.StartAsClient();
     }
 
     override public void OnClientDisconnect(NetworkConnection conn)
     {
         base.OnClientConnect(conn);
 
         StopClient();
         enabled = false;
         netDiscovery.enabled = false;
         Invoke("ProcessDisconnect", 0.5f);
     }
     
     void ProcessDisconnect()
     {
         enabled = true;
 
         netDiscovery.enabled = true;
         netDiscovery.Initialize();
         netDiscovery.StartAsClient();
     }
 
 

NetworkDiscovery :

     public delegate void BroadcastEvent(string fromAddress, string data);
 
     public event BroadcastEvent OnReceivedNetworkBroadcast = delegate { };
 
     override public void OnReceivedBroadcast(string fromAddress, string data)
     {
         OnReceivedNetworkBroadcast(fromAddress, data);
     }
 
 


Comment
Add comment · Show 3
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 hexagonius · Jul 26, 2018 at 02:25 PM 0
Share

What version of Unity are you running this on?

avatar image HiwackVDP hexagonius · Jul 27, 2018 at 09:33 AM 0
Share

I've tried to run it on 2018.2.0f2 and 2017.2.0f3

avatar image hexagonius HiwackVDP · Jul 27, 2018 at 08:12 PM 0
Share

this is beyond weird. the Sourcecode is free to view on bitbucket and the first statement in the NetworkDiscovery's Update is a return when hostID is -1. no debugs or anything.
I can't help here, never had that problem with my network projects but I never ever used that component not good I override it...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Fattie · Oct 08, 2018 at 09:17 PM

Regarding this infuriating problem caused by Unity's shoddy network code.

  • Just on your PCs/Macs, check you are getting good internet connection (ie, can you get to ordinary web sites fast)

  • Ensure that in the Unity project, you have "run in background" on

  • Often it will work "one way and not the other way". Swap around your two PCs/Macs as client/server .. and it will work the other way. Really stupid and infuriating.



And for late 2018 Unity introduced a new problem:

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

on that essay carefully note the "aside" added in RED - that will fix the problem in many cases. Infuriating!



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

131 People are following this question.

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

Related Questions

TextMesh multiplayer/network issue 0 Answers

Unity not recognizing my scripts 0 Answers

[C#]CalcHeight issues 1 Answer

Cannot use Network Transform Child in unity 2019.1of2 3 Answers

Netcode not working on Quest 1 Answer


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