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
2
Question by marcelop · Mar 07, 2016 at 07:57 PM · networkingserverresetlobby

LobbyManager / NetworkManager doesn't reset properly

I'm having trouble making the LobbyManager (which inherits from NetworkManager) work again after a successful online match. There is no documentation at all on how to do this, especially in regards to the LobbyManager. I have tried many different ways of resetting it, including disconnecting all connections, calling StopClient and StopServer, calling NetworkServer.Shutdown, NetworkServer.Reset, and also many of these or all of these at the same time.

The server restarts normally, and apparently the local client is able to connect to it. However, whenever a remote client connects to the reset server, it jumps to the playScene directly, as if all clients had signaled they were ready, or as if it still thought the match was not finished. Since I can't find any documentation on this, I simply cannot know if I'm doing something wrong, or if this is a Unity bug. So I guess my question is: What should we do to properly reset the LobbyManager?

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 Anisoropos · Mar 13, 2017 at 12:16 PM 0
Share

Hi, did you ever find a solution for this? I'm creating a match -> exiting -> and then can't create a new one ("A connection has already been set as ready. There can only be one.").

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by bliu886 · Jan 24, 2018 at 05:53 PM

For anyone still looking for an answer, this seems to happen because the server isn't being fully shutdown and connections are still open. In Unity version 2017.2.0f3, to fully close all the server connections and ports in the LobbyManager is calling Shutdown(). Here is some sample code:

 public override void OnServerDisconnect(NetworkConnection conn)
 {
     Debug.Log("Client disconnected: " + conn.lastError);
 
     // Removes the player game object from the world.
     NetworkServer.DestroyPlayersForConnection(conn);
 
     // Stop listening on the port, but port is still open and world state is kept.
     int id = PlayerByConnection(conn.connectionId);
     playerList.Remove(playerList[id]);
 
     // The last person in the game left.
     if (playerList.Count < 1)
     {
         // Forces the server to shutdown.
         Shutdown();
 
         // Reset internal state of the server and start the server again.
         Start();
     }
 }
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
avatar image
1

Answer by joaokan · Nov 06, 2018 at 10:07 AM

A little late to the party, but I've had this problem for a while and finally got to fix it today. Turns out that the NetworkManager has a static variable called networkSceneName which is not reset when the server shuts down. So the next time the server starts, every client that connects will be sent a message to change to the active network scene of the previous game. Resetting this variable to "" after calling Shutdown() solved the issue for me.

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
avatar image
1

Answer by Kurius · Feb 27, 2019 at 11:18 PM

I know this is an old thread but it's a top Google search result. What finally solved it for me was to have the client locate the host player GameObject, then call Command and ClientRpc methods via the Host in order to simulate the Host leaving the game and thus ending the game for everybody. This was the only full proof method for the Client to be able to successfully leave the current networked multiplayer game (but not quit the app), then join a new networked game. I know this is not an ideal solution, but it works 100% of the time.

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
avatar image
0

Answer by transporter_gate_studios · Mar 06, 2018 at 08:11 PM

can you share some code? I'm having the same problem. I'd like to be able to have a user exit and host a new server without having to restart the application

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

58 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

Related Questions

Unity networking tutorial? 6 Answers

Dedicated server lobby problem 0 Answers

Network Lobby/Manager - Spawn player when I tell it to 1 Answer

New multiplayer setting broke Network Lobby 0 Answers

How to make just a simple server to save arrays and vars for a multiplayer? 0 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