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 _AkSeL_ · Jun 09, 2017 at 05:20 PM · networkingmemoryapimatchmakingtransport

NetworkMatch Request Error Out of memory

I'm trying to use NetworkMatch with NetworkTransport as described unity's documentation here.

When listing matches, I have an Out of memory error and I can't find anything anywhere about this :

Exception: Match list failed : Request error:[Out of memory] Raw response:[] AVR.network.MyNetworkManager.OnMatchList (Boolean success, System.String extendedInfo, System.Collections.Generic.List²1 matches) (at Assets/Scripts/Network/MyNetworkManager.cs:207) UnityEngine.Networking.Match.NetworkMatch.OnMatchList (UnityEngine.Networking.Match.ListMatchResponse response, UnityEngine.Networking.Match.DataResponseDelegate²1 userCallback) (at C:/buildslave/unity/build/Runtime/Networking/Managed/MatchMakingClient.cs:357) UnityEngine.Networking.Match.NetworkMatch+c__Iterator0²2[UnityEngine.Networking.Match.ListMatchResponse,UnityEngine.Networking.Match.NetworkMatch+DataResponseDelegate²1[System.Collections.Generic.List²1[UnityEngine.Networking.Match.MatchInfoSnapshot]]].MoveNext () (at C:/buildslave/unity/build/Runtime/Networking/Managed/MatchMakingClient.cs:438) UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

I'm using a simple NetworkManager script that deals with only one match : if the match is not created, it creates it, else it joins the match.

The problem is in updatePlayerCount() wich just ask for the number of currently connected players, and in JoinOthers() wich joins an already created match:

     matchMaker.ListMatches(0, 1, MATCH, false, 0, 0, OnMatchListCountPlayers);
 [...]
  public void OnMatchListCountPlayers(bool success, string extendedInfo, List<MatchInfoSnapshot> matches)
          {
              if (!success)
                  throw new System.Exception("Match list failed : " + extendedInfo);

Here is the complete NetworkManager script I use:

 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Threading;
 using UnityEngine;
 using UnityEngine.Events;
 using UnityEngine.Networking;
 using UnityEngine.Networking.Match;
 using UnityEngine.Networking.Types;
 using UnityEngine.SceneManagement;
 
 namespace AVR.network
 {
     [System.Serializable]
     public class MyNetworkManager : MonoBehaviour
     {
         private const int BUFFER_SIZE = 1024;
         private const string MATCH = "ITER";
 
         private MatchInfo currentMatch = null;
         private bool connectionDroped = false;
 
         private int nPlayersOnline = -1;
         public int NPlayersOnline { get { return nPlayersOnline;  } }
 
         private bool isStarted = false;
         public bool IsStarted { get { return isStarted; } }
 
         private bool isServer;
         public bool IsServer { get { return isServer; } }
 
         private bool isMatchCreator;
         public bool IsMatchCreator { get { return isMatchCreator; } }
 
         private NetworkMatch matchMaker;
         private UnityAction callback;
 
         [System.Serializable]
         public class SpawnInfo
         {
             public string propertyName;
             public string propertyValue;
             public GameObject toSpawn;
         }
         public List<SpawnInfo> toSpawn;
 
         private const int MAX_CONNECTION = 100;
         private int port = 7543;
         private int hostId;
         private int webHostId;
         private int reliableChannel;
         private int unreliableChannel;
         private byte error;
         private string playerName;
         private int connectionId;
         private float connectionTime;
         private int recHostId;
         private int channelId;
         private byte[] recBuffer = new byte[BUFFER_SIZE];
         private int bufferSize = BUFFER_SIZE;
         private int dataSize;
         private NetworkEventType recData;
 
         private Message msg;
 
 
         void Awake()
         {
             matchMaker = gameObject.AddComponent<NetworkMatch>();
             Application.runInBackground = true;
             DontDestroyOnLoad(gameObject);
         }
 
         void Start()
         {
             if (Simulation.Instance != null)
                 Simulation.Instance.NetworkManager = this;
             StartCoroutine(updatePlayerCount());
         }
 
         public void JoinOthers(string pName, UnityAction callback = null)
         {
             this.callback = callback;
             this.playerName = pName;
             if (matchMaker != null)
                 matchMaker.ListMatches(0, 1, MATCH, false, 0, 0, OnMatchList);
             else
                 Debug.Log("Error with matchMaker !");
         }
 
         public void StartAlone(string pName, UnityAction callback = null)
         {
             this.callback = callback;
             this.playerName = pName;
         }
 
         private void startServer()
         {
             NetworkTransport.Init();
             ConnectionConfig cc = new ConnectionConfig();
             reliableChannel = cc.AddChannel(QosType.Reliable);
             unreliableChannel = cc.AddChannel(QosType.Unreliable);
             HostTopology topo = new HostTopology(cc, MAX_CONNECTION);
 
             hostId = NetworkTransport.AddHost(topo, port, null);
             webHostId = NetworkTransport.AddWebsocketHost(topo, port, null);
 
             isStarted = true;
             isServer = true;
             if (callback != null)
                 callback.Invoke();
             Debug.Log("Server started on port " + port);
         }
 
         private void startClient(string serverIPAdress)
         {
             NetworkTransport.Init();
             ConnectionConfig cc = new ConnectionConfig();
             reliableChannel = cc.AddChannel(QosType.Reliable);
             unreliableChannel = cc.AddChannel(QosType.Unreliable);
             HostTopology topo = new HostTopology(cc, MAX_CONNECTION);
 
             hostId = NetworkTransport.AddHost(topo);
             connectionId = NetworkTransport.Connect(hostId, serverIPAdress, port, 0, out error);
             isStarted = true;
             isServer = false;
             connectionTime = Time.time;
 
             isStarted = true;
             if (callback != null)
                 callback.Invoke();
 
             Debug.Log("Client connected.");
         }
 
         private void Update()
         {
             if (!IsStarted)
                 return;
 
             if (isServer)
                 serverLoop();
             else
                 clientLoop();
         }
 
         private void serverLoop()
         {
             recData = NetworkTransport.Receive(out recHostId, out connectionId, out channelId, recBuffer, bufferSize, out dataSize, out error);
             switch (recData)
             {
                 case NetworkEventType.Nothing:         //1
                     break;
                 case NetworkEventType.ConnectEvent:    //2
                     Debug.Log("Client " + connectionId + " has connected.");
                     break;
                 case NetworkEventType.DataEvent:       //3
                     msg = Message.Deserialize(recBuffer);
                     Debug.Log("Client " + connectionId + " has sent : " + msg);
                     break;
                 case NetworkEventType.DisconnectEvent: //4
                     Debug.Log("Client " + connectionId + " has disconnected.");
                     break;
             }
         }
 
         private void clientLoop()
         {
             recData = NetworkTransport.Receive(out recHostId, out connectionId, out channelId, recBuffer, bufferSize, out dataSize, out error);
             switch (recData)
             {
                 case NetworkEventType.Nothing:         //1
                     break;
                 case NetworkEventType.ConnectEvent:    //2
                     break;
                 case NetworkEventType.DataEvent:       //3
                     break;
                 case NetworkEventType.DisconnectEvent: //4
                     break;
             }
         }
 
         public IEnumerator updatePlayerCount()
         {
             while (! IsStarted)
             {
                 if (matchMaker != null)
                     matchMaker.ListMatches(0, 1, MATCH, false, 0, 0, OnMatchListCountPlayers);
                 yield return new WaitForSeconds(Simulation.Instance.InternetMatchRefreshRate);
             }
             yield break;
         }
 
         public void OnMatchListCountPlayers(bool success, string extendedInfo, List<MatchInfoSnapshot> matches)
         {
             if (!success)
                 throw new System.Exception("Match list failed : " + extendedInfo);
             if (matches.Count == 0)
                 nPlayersOnline = 0;
             else
                 nPlayersOnline = matches[0].currentSize;
         }
 
         public void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matches)
         {
             if (!success)
                 throw new System.Exception("Match list failed : " + extendedInfo);
 
             if ((matches.Count == 0) || (matches[0].currentSize == 0))
                 createMatch();
             else
             {
                 Debug.Log("Joining match " + matches[0].name + " with " + matches[0].currentSize + " players in it, from a list of " + matches.Count + " matches.");
                 joinMatch(matches[0].networkId);
             }
         }
 
         private void joinMatch(NetworkID id)
         {
             matchMaker.JoinMatch(id, MATCH, "", "", 0, 0, OnMatchJoined);
         }
 
         public void OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo)
         {
             if (!success)
                 throw new System.Exception("Match join failed.");
 
             currentMatch = matchInfo;
             MatchInfo hostInfo = matchInfo;
             isMatchCreator = false;
             startClient(hostInfo.address);
         }
 
         private void OnApplicationQuit()
         {
             Debug.Log("On application quit");
             if ((matchMaker != null) && (currentMatch != null))
                 matchMaker.DropConnection(currentMatch.networkId, currentMatch.nodeId, 0, (a, b) => { ; });
             if ((IsMatchCreator) && (matchMaker != null))
                 matchMaker.DestroyMatch(currentMatch.networkId, 0, OnMatchDropConnection);
 
             int i = 0;
             while ((i < 10) && (!connectionDroped))
             {
                 Thread.Sleep(100);
                 i++;
             }
 
             Destroy(matchMaker);
         }
 
         public void OnMatchDropConnection(bool success, string extendedInfo)
         {
             Debug.Log("Connection drop " + (success ? "success ! " : "falure ! ") + "extendedInfo = " + extendedInfo);
             connectionDroped = true;
         }
 
         private void createMatch()
         {
             matchMaker.CreateMatch(MATCH, 10, true, MATCH, "", "", 0, 0, OnMatchCreate);
         }
 
         public void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo)
         {
             if (!success)
             {
                 Debug.LogError("Match creation failed : " + extendedInfo);
                 Debug.LogError("Match info : " + matchInfo);
                 throw new System.Exception("Match creation failed : " + extendedInfo);
             }
 
             Debug.Log("on match create, server active = " + NetworkServer.active);
             Debug.Log("matchInfo = " + matchInfo);
 
 
             currentMatch = matchInfo;
             isMatchCreator = true;
             startServer();
         }
     }
 }


Any help would be greatly appreciated !

Comment
Add comment
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

1 Reply

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

Answer by _AkSeL_ · Jun 17, 2017 at 08:28 AM

The error is actually that two versions of the same project were connecting to the multiplayer service with the same ID. This should not raise an out of memory error but more something related to the ID used. Bug filed here : https://fogbugz.unity3d.com/default.asp?918528_iumo80ak8eo3ig1f

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unet Multiplayer Not working 1 Answer

UNET Matchmaking - Unable to force regions 0 Answers

Cannot start Matchmaking online game 0 Answers

Best solution for low bandwidth multiplayer game 1 Answer

How can i spawn my player in matchmaker using my UI? 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