[SOLVED] Error When Creating Multiplayer Lobby

Hello!

Not sure if this is the right place to post this, as I am trying to create my own GUI for the NetworkLobbyManager in Unity 5.4 Beta. Right now, I’m mostly having a hard time figuring out what code I need to start the MatchMaker Lobby. I’ve tried looking through documentation and through examples by others, but things are a mess since the Networking code has been simplified since 5.3. Here’s some code that I was trying out. I can’t seem to get any lobbies working. What am I missing? Is there somewhere other than the documentation that could provide me with more clear directions?

Thanks in advance for any help that you can provide.

Show Code

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using System.Collections;

public class MainMenuBehavior : MonoBehaviour
{
   public NetworkLobbyManager mgr;

   public GameObject MainMenuPanel;
   public GameObject CreateGamePanel;
   public GameObject JoinGamePanel;
   public GameObject SettingsPanel;
   public GameObject CreditsPanel;

   private string PlayerName;

   private string MatchName;
   private string MatchPassword;

   public bool isLan = false;

   void Awake()
   {
     mgr.StartMatchMaker();
   }

   /***
    * Begin Button Network Functionality Code
   ***/
   public void OnHostLAN()
   {
     isLan = true;
   }

   public void OnHostMatchMaker()
   {
     isLan = false;
   }

   // Creates A Lobby
   public void OnCreateLobby()
   {
     if (isLan)
     {
       mgr.matchMaker.CreateMatch("Test Game LAN", 8, true, "", "public address", "private address", 0, 0, mgr.OnMatchCreate);
       // TODO: Setup Connection To LAN Lobby
     }
     else
     {
       mgr.matchMaker.CreateMatch("Test Game Matched", 8, true, "", "", "", 0, 0, mgr.OnMatchCreate);
       // TODO: Setup Connection To Non-LAN Lobby
     }
   }

   // This Attempts to Connect To A Lobby
   public void OnConnectToLobby()
   {
   }

   // This Refreshes The List Of Lobbies
   public void OnRefreshGames()
   {
   }
   /***
    * End Button Network Functionality Code
   ***/

   /***
    * Begin GUI Controller Code
   ***/
   public void OnCreateMultiplayerMenu()
   {
     if (MainMenuPanel != null)
       MainMenuPanel.SetActive(false);
     if (CreateGamePanel != null)
       CreateGamePanel.SetActive(true);
     else
       MainMenuPanel.SetActive(true);
     if (JoinGamePanel != null)
       JoinGamePanel.SetActive(false);
     if (SettingsPanel != null)
       SettingsPanel.SetActive(false);
     if (CreditsPanel != null)
       CreditsPanel.SetActive(false);
   }

   public void OnJoinMultiplayerMenu()
   {
     if (MainMenuPanel != null)
       MainMenuPanel.SetActive(false);
     if (CreateGamePanel != null)
       CreateGamePanel.SetActive(false);
     if (JoinGamePanel != null)
       JoinGamePanel.SetActive(true);
     else
       MainMenuPanel.SetActive(true);
     if (SettingsPanel != null)
       SettingsPanel.SetActive(false);
     if (CreditsPanel != null)
       CreditsPanel.SetActive(false);
   }

   public void OnSettingsMenu()
   {
     if (MainMenuPanel != null)
       MainMenuPanel.SetActive(false);
     if (CreateGamePanel != null)
       CreateGamePanel.SetActive(false);
     if (JoinGamePanel != null)
       JoinGamePanel.SetActive(false);
     if (SettingsPanel != null)
       SettingsPanel.SetActive(true);
     else
       MainMenuPanel.SetActive(true);
     if (CreditsPanel != null)
       CreditsPanel.SetActive(false);
   }

   public void OnCreditsMenu()
   {
     if (MainMenuPanel != null)
       MainMenuPanel.SetActive(false);
     if (CreateGamePanel != null)
       CreateGamePanel.SetActive(false);
     if (JoinGamePanel != null)
       JoinGamePanel.SetActive(false);
     if (SettingsPanel != null)
       SettingsPanel.SetActive(false);
     if (CreditsPanel != null)
       CreditsPanel.SetActive(true);
     else
       MainMenuPanel.SetActive(true);
   }

   public void OnQuitGameMenu()
   {
   }

   public void OnReturnToMainMenu()
   {
     mgr.StopMatchMaker();

     if (CreateGamePanel != null)
       CreateGamePanel.SetActive(false);
     if (JoinGamePanel != null)
       JoinGamePanel.SetActive(false);
     if (SettingsPanel != null)
       SettingsPanel.SetActive(false);
     if (CreditsPanel != null)
       CreditsPanel.SetActive(false);
     if (MainMenuPanel != null)
       MainMenuPanel.SetActive(true);
   }
   /***
    * END GUI Controller Code
   ***/
}

EDIT: Updated the code.

EDIT #2: Here’s the error I’ve been getting when trying to create a lobby.
Show Error Message NetworkLobbyManager can’t accept new connection [hostId: -1 connectionId: 0 isReady: False channel count: 0], not in lobby and game already in progress.

Anyone able to help me fix this error and/or tell me what I’m doing wrong? Searches for the error have yielded no results, thus far.

Anybody?

Bump…

Anybody have an answer to this?

I think most people use this asset from Unity Technologies as a starting point for the lobby.

To make it work with 5.4, there are some changes to the matchmaking class that will need to be made manually.

Hrm, okay. I’ll check this out and see if I can get things working.

I have everything up and working and have successfully been able to modify the code to work within my GUI system. Thanks for the help!

1 Like

EDIT : Ok my bad. I was using a pre-dated scene as the lobby scene. :confused:

Hello,
I have been using Unity 5.5.0p4 and right now i am changing the artwork for the lobby.
And i am getting the same error:

NetworkLobbyManager can’t accept new connection

full error

NetworkManager:OnServerConnectInternal
UnityEngine.Networking.NetworkManager:OnMatchCreate(Boolean, String, MatchInfo)
Prototype.NetworkLobby.LobbyManager:OnMatchCreate(Boolean, String, MatchInfo) (at Assets/Lobby/Scripts/Lobby/LobbyManager.cs:246)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

NetworkLobbyManager can’t accept new connection [hostId: -1 connectionId: 0 isReady: False channel count: 0], not in lobby and game already in progress.
UnityEngine.Networking.NetworkManager:OnMatchCreate(Boolean, String, MatchInfo)
Prototype.NetworkLobby.LobbyManager:OnMatchCreate(Boolean, String, MatchInfo) (at Assets/Lobby/Scripts/Lobby/LobbyManager.cs:246)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

RegisterHandlerSafe id:1 handler:OnLocalClientObjectDestroy
UnityEngine.Networking.NetworkManager:OnMatchCreate(Boolean, String, MatchInfo)
Prototype.NetworkLobby.LobbyManager:OnMatchCreate(Boolean, String, MatchInfo) (at Assets/Lobby/Scripts/Lobby/LobbyManager.cs:246)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

I get this error as soon as i create the new match. if i close that panel and create a new match it works.
Any chance you can share how you solved this error?

1 Like

I’m going to bump this in hopes that someone can provide a solution rather than a workaround. I’m familiar with the lobby example on the asset store, but the built in gui system for Unity doesn’t play nice with VR. I’ve developed my own gui system instead, so I’d rather not go through the trouble of getting the example to work with my system. I’ve tried to keep things pretty simple, but I’m not sure what’s going on here. Literally the only piece of networking code I’ve added so far is a call to StartHost(), which raises this error. It actually worked perfectly fine the very first time I ran it in the editor, but hasn’t worked since. I thought this might be due to a socket not being closed properly or something, but restarting my computer, restarting my modem, and changing the port have had no effect on the problem. Any help would be appreciated.

1 Like

Anyone else having this problem may be because your lobby scene in your networkmanager component is not the correct scene. Changing it to the current lobby scene proactively fixed it for me.