Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unity Multiplayer Can't use matchmaker on different computer?

Discussion in 'Connected Games' started by CaretCaret, Jun 16, 2015.

  1. CaretCaret

    CaretCaret

    Joined:
    Mar 7, 2015
    Posts:
    9
    I got my networking going in my game and wanted to try it over the internet. So I tried the Matchmaker and it seemed to work, I could join myself on the same computer, but then when I ran the game on a different computer it just said "Failed CreateMatch for appId=Invalid]-addres:,port:0"... and then everything set to a bunch of zeros.

    Have I missed something or why would it only work on my machine?
     
  2. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    We are running into this as well. We followed tutorials and demos and nothing seems to be working.
     
  3. JeremyUnity

    JeremyUnity

    Unity Technologies

    Joined:
    Mar 4, 2014
    Posts:
    147
    "Failed CreateMatch for appId=Invalid" means either the project GUID wasn't setup or there was a problem when it was pasted into the player prefs field (there's some stuff that happens behind the scenes when that GUID is pasted in).

    If you run into that please go to https://multiplayer.unity3d.com again, login and make sure your project is set up. Take the guid from there and go to Edit -> Project Settings -> Player and clear out the "Cloud Project ID" if anything is there and paste the GUID you got from the web page.

    After that everything should work, though unfortunately every developer will have to do this right now if the project is shared. We're working on improving that soon.
     
  4. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    We have done that, and what will happen is it will become invalid after the build. When we go into the field and re-paste it, it will work for a couple of builds then go 'bad' again. It is a crapshoot if the build actually works with a valid AppID.

    Our other issue is that even with a valid AppID that we cannot see other matches created across the internet. There are no errors, no issues, just no matches.
     
  5. JeremyUnity

    JeremyUnity

    Unity Technologies

    Joined:
    Mar 4, 2014
    Posts:
    147
    Matches time out after 30 seconds if they haven't talked to relay server via the LLAPI, and at that point the matchmaker wouldnt list them. Provided you're in a match it will keep the connection alive automatically.

    If you have repro steps for the matchmaker not showing a match that's alive let me know and i'll look into it.
     
  6. CaretCaret

    CaretCaret

    Joined:
    Mar 7, 2015
    Posts:
    9
    When you say everyone who is working on it has to do it, does this mean I must have a logged-in installation on the other computer I test the build on?

    What is happening for me is that I make a build. And it works on the computer I made the build on, I can matchmake and no error. It works as it should. Then I sent the build to a friend and they couldn't connect to the matchmaker, they got the error. Thinking this was maybe a problem with their connection I tried it on my other computer connected to the same router as the one that it worked on. But It didn't work and I got the error. Neither of the other computers has unity installed.
     
  7. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    268
    There is an issue with persisting the multiplayer ID used when you start matches. To get past this you can set the ID manually with NetworkMatch.SetProgramAppID. You'll find this ID below the Cloud Project ID of your project at https://multiplayer.unity3d.com (called UNET ID here). Using the Project ID should link the multiplayer ID automatically, but this fails and proper fix for that will come. When you use the NetworkManager and NetworkManagerHUD components you could call something like this in some script to force the ID this way (replace XXX with the ID found on the multiplayer webpage):
    Code (CSharp):
    1. NetworkManager.singleton.StartMatchMaker();
    2. NetworkManager.singleton.matchMaker.SetProgramAppID((AppID)XXX)
    If you are customising the NetworkManager (use it as base class) or doing it differently you can just call those directly instead in your custom script:
    Code (CSharp):
    1. StartMatchMaker();
    2. matchMaker.SetProgramAppID((AppID)XXX);
    If using the basic script found in the manual add a networkMatch.SetProgramAppID call in Awake.
     
  8. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    We tried that code and now we don't get the invalid ID error on builds, but we still cannot see any hosts that are not on the same machine as the client. If we open a client on the same machine we can see it, but otherwise we get nothing at all. We are using the example 'balls' program that is provided as a UNET example so this is about as simple as it gets. We have tested this on internal and external networks.
     
  9. CaretCaret

    CaretCaret

    Joined:
    Mar 7, 2015
    Posts:
    9
    I'm confused about how I replace XXX with the ID. If I try to add it as a string it says it can't convert from a string. What am I supposed to do exactly?
     
  10. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Use the 'UNET ID' that is on the bottom left of the multiplayer config screen. It is an integer and gets converted correctly.
     
  11. CaretCaret

    CaretCaret

    Joined:
    Mar 7, 2015
    Posts:
    9
    Oh, that tiny thing ^^
    Thank you, it worked :D
     
  12. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Yeah, I put it in the code as a 'well, lets just try this number' and was surprised it worked.

    Are you able to get a game visible across the net? We have been messing with this for over a week and still can't see a game when looking across the internet.
     
  13. CaretCaret

    CaretCaret

    Joined:
    Mar 7, 2015
    Posts:
    9
    Yes, I sent it to my friend who could previously not create or search for games, but now they could and I could join the game without problem. I haven't tested more than that though.
    I'm using all the standard Network Manager and HUD components.
     
  14. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    Then I have no clue what we are doing wrong. We are using the example 'move' project and cannot get the game to show in the list if we do anything but a local connection. I am using 5.1.1 Pro and it is not working at all.

    Do you have a simple test project that works that we could look at? I am thinking it has to be something rather simple that is missing in our setup.
     
  15. CaretCaret

    CaretCaret

    Joined:
    Mar 7, 2015
    Posts:
    9
    I don't have anything that I can share, but all I have touched in regards to matchmaking is set up the Manager and the HUD component, barely changed any setting, just put in my player prefab and stuff, and then added the Cloud Project ID in the player settings and lastly added that SetProgramAppID code to run on awake. Don't think I have done anything else.
     
  16. Regin96

    Regin96

    Joined:
    Mar 14, 2015
    Posts:
    4
    Hm, I also use the prebuild Manager and HUD and it still doesn't work at all over the Internet. My friend clicks the button but nothing happens, while I can use it fine on my machine. Thats weird so, we use the same files and his buttons do nothing (matchmaker) while LAN buttons work.

    Any advice?
     
  17. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    We removed the gameobject that had the NetworkManager and the NetworkManagerHUD, created a script that did the set of the ID in Awake, put that on a new gameobject with bone stock NetworkManager and NetworkManagerHUD components and for SOME reason it works this time.
     
  18. Regin96

    Regin96

    Joined:
    Mar 14, 2015
    Posts:
    4
    Doing that gives me a nice
    "NullReferenceException: Object reference not set to an instance of an object"
     
  19. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    In the last update from Unity it did for us as well, my new script is like this now.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.Networking;
    4. using UnityEngine.Networking.Types;
    5.  
    6. public class NewStartup : MonoBehaviour {
    7.     bool setNM = false;
    8.  
    9.     // Update is called once per frame
    10.     void Update () {
    11.         if (NetworkManager.singleton != null && setNM == false)
    12.         {
    13.             NetworkManager.singleton.StartMatchMaker();
    14.             NetworkManager.singleton.matchMaker.SetProgramAppID((AppID)12345);
    15.             setNM = true;
    16.         }
    17.     }
    18. }
    I imagine you don't need the 'setNM' variable, but I wanted it to ignore the section and only run it once, just in case the singleton lost its value for one loop as a quirk that id didn't try to start the matchmaker again.
     
  20. Regin96

    Regin96

    Joined:
    Mar 14, 2015
    Posts:
    4
    I am just wondering whether that will fix my issue or not as I am not sure that we got the same issue. Could the second person press the join or create match button in the matchmaker tab?
     
  21. HugoZandel

    HugoZandel

    Joined:
    Mar 11, 2014
    Posts:
    52
    I'm getting an issue where the client is trying to join an invalid game. (The host already left the game) I'm getting an error and I'm not sure how to catch it and make the user join another game.

    Code (CSharp):
    1. UNet Client Disconnect Error: Timeout
    2. UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
     
  22. Anisoropos

    Anisoropos

    Joined:
    Jul 30, 2012
    Posts:
    93
  23. TomzaiML

    TomzaiML

    Joined:
    Aug 4, 2015
    Posts:
    4
    I'm running into a similar problem. Using Unity 5.2.1, I've created a new project with the stock NetworkManager and NetworkManagerHUD, and it's correctly configured with a project on https://multiplayer.unity3d.com.
    When I use two devices (e.g. two PCs or PC and Android) on the same network, I can create a match on one device and successfully connect to it on the other device via matchmaking. However if the devices are on separate networks then I can never see the match created on the first device on the second device. There are no errors or warnings - just no matches listed. This is what's logged - 'JSON Response: [[UnityEngine.Networking.Match.ListMatchResponse]-success:True-extendedInfo:]-matches.Count:0'
    I've also tried it with and without CaptainMurphy's 'NewStartup' script - it doesn't seem to make any difference.
    Are there any network settings that might interfere with the matchmaking across networks?
     
  24. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    643
    I'm having the exact same issue as @TomzaiML

    EDIT - This THREAD actually solved my problem.
     
    Last edited: Oct 20, 2015
  25. PizzaPirate

    PizzaPirate

    Joined:
    Apr 2, 2015
    Posts:
    5
    Im having the same problem that @Tomazai is having. But that thread didn't fix my issue.
    Using the code to set my project ID is also throwing me an exception
     
unityunity