Search Unity

Unity Multiplayer [Solved] CreateMatch does't invoke callback on mobiles

Discussion in 'Multiplayer' started by Xaon, Aug 24, 2016.

  1. Xaon

    Xaon

    Joined:
    Feb 28, 2013
    Posts:
    59
    Hi.

    I'm creating a maily mobile game that uses matchmaker. I've been testing in editor and on standalone builds and everything works ok. But when I run it on mobile (Android) build matchmaker doesn't invoke callbacks.

    One of tests tha I've made:
    1. Run game on mobile and in Editor
    NetworkLobbyManager(Instance).StartMatchMaker() on both
    2. In mobile build invoke NetworkLobbyManager(Instance).matchMaker.CreateMatch(... , OnMatchCreatedCallback)
    Here I've got log: MatchMakingClient Create :https://mm.unet.unity3d.com/json/reply/CreateMatchRequest
    and event if I wait couple of minuted the OnMatchCreatedCallback isn't called.
    3. In Editor invoke NetworkLobbyManager(Instance).matchMaker.ListMatches(... , OnMatchListReceivedCallback)
    Almost instantly the OnMatchListReceivedCallback is called, game hosted on mobile is listed and I can join it with no problem.

    If I try the other way: host game in Editor and try to connect from mobile, then again. Everything works great in Editor and on mobile I don't receive any callbacks on mobile.

    I've tested it on two different Android devices.

    I would be glad for any hints.
    I'm using Unity Personal. I've set up Unity Multiplayer for this project. Is there any extra configuration step for debug mobile builds? Is there a workaround/other way to check if there is response from relay server? Or maybe it's a known bug?

    Thanks in advance.
     
  2. Xaon

    Xaon

    Joined:
    Feb 28, 2013
    Posts:
    59
    [Solved]

    I've tried Tanks Networking example and match making is working on Android so it's not an engine issue.
    I've also tried to test match maker with vanilla NetworkLobbyManager, NetworkHUD etc components on my project and it doesn't work on Android (there is no problem in Editor). So it's not problem with my code. The only difference left is the project itself.

    After checking Android Monitor I've found message:
    "MissingMethodException: Method not found: 'Default constructor not found...ctor() of UnityEngine.Networking.Match.CreateMatchResponse'."

    The solution is set Stripping Level to Disabled. I've tried all Stripping Level, only Disabled works.

    Additional fact.
    Size of the build is 32.7MB Stripping Level disabled where with any stripping level the build size is 31.7MB.
     
  3. Valdeco

    Valdeco

    Joined:
    Sep 7, 2014
    Posts:
    11
    Another solution, if you don't want to disable code stripping, is to add a new MonoBehaviour (say PreventStrippingBehaviour) to an empty scene, add the scene in BuildSettings (you don't ever need to open it, but it needs to be included in build) and on PreventStrippingBehaviour Awake method instantiate each of the missing classes. In my case, those 5 were enough:

    void Awake()
    {
    // prevent unity from stripping classes
    new CreateMatchResponse();
    new ListMatchResponse();
    new MatchDesc();
    new MatchDirectConnectInfo();
    new JoinMatchResponse();
    }
     
  4. Valdeco

    Valdeco

    Joined:
    Sep 7, 2014
    Posts:
    11
unityunity