Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 KdRWaylander · Apr 16, 2015 at 08:39 AM · errorserverclientclient-serverdisconnect

Error: "A client which was not in the connected player list disconnected. ???"

Hi,

I have two locally connected applications, one being the server, the other being the client. It always worked with my differents builds but this time I have the strangest error:

alt text

I don't have any messages in the console saying that a player has connected/disconnected, I only have "Server created" and this error. I should say that both applications works perfectly independently ...

Here's my code:

Server:

 using UnityEngine;
 using System.Collections;
 using System.Diagnostics;
 using UnityEngine.UI;
 
 public class ServerPropsMVR : MonoBehaviour {
     /* VARIABLES */
     int nbClient = 5;
     int nbPort = 25000;
     bool useNat = false;
 
     public Text connexionStatusText;
     int playerCount;
 
     /* INITIALISATION */
     void Start (){
         playerCount = 0;
 
         Network.InitializeServer (nbClient,nbPort,useNat);
 
         Process.Start("MVR_Oculus_AsClient");
     }
 
     /* MESSAGES */
     void OnServerInitialized () {
         UnityEngine.Debug.Log ("Server created");
     }
 
     void OnPlayerConnected () {
         UnityEngine.Debug.Log ("Client connected");
         playerCount++;
 
         if (playerCount > 0) {
             connexionStatusText.text = "Connected";
             connexionStatusText.color = Color.green;
         }
     }
 
     void OnPlayerDisconnected () {
         UnityEngine.Debug.Log ("Client disconnected");
         playerCount--;
 
         if (playerCount < 1) {
             connexionStatusText.text = "Disconnected";
             connexionStatusText.color = Color.red;
         }
     }
 }

Client:

 using UnityEngine;
 using System.Collections;
 
 public class ClientPropsMVR : MonoBehaviour {
     // Server properties
     string serverIP = "127.0.0.1";
     int serverPort = 25000;
 
     /* INITIALISATION */
     void Update(){
         if (Network.peerType == NetworkPeerType.Disconnected)
             Network.Connect(serverIP, serverPort);
     }
 
     /* MESSAGES */
     void OnConnectedToServer () {
         Debug.Log ("Connected to server");
     }
 
     void OnApplicationQuit () {
         Network.Disconnect (200);
     }
 }


consoleerror.jpg (24.7 kB)
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 KdRWaylander · Apr 29, 2015 at 08:43 AM 0
Share

Anyone here ?

1 Reply

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

Answer by Cheryl_Dwyer · Nov 01, 2015 at 11:00 PM

Well, this is quite an old post, and you've probably figured it out already, but I'll write this anyway. This exception, as the error states, is thrown when a player who's not in the connected player list disconnects - so the question is why that player was not in the list. From my experience, this occurs when a client connects and then disconnects again in the same frame (probably before the server has time to add them), so check any methods called once a frame (like Update() and so on) for Network.Disconnect() or Network.CloseConnection(). Also, you don't need to keep track of the player count yourself. Unity keeps a list of all the connected NetworkPlayers, so you can get the number of players by checking the list's length : Network.connections.Length. Hope this helped!

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 KdRWaylander · Jan 14, 2016 at 12:18 PM 0
Share

Hey man, thanks for the answer ! A bit late indeed, i moved to another project and Unity changed its network system meanwhile ... but anyway i'll keep it in $$anonymous$$d next time ! Cheers

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

18 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

Related Questions

Time problem with Joining to Multilayer game 1 Answer

Unity Networking - Clients scattered around scenes 0 Answers

OnConnectedToServer not working 1 Answer

Can anyone help me with my network script? 1 Answer

Node.js Problem 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