question

Travis Lange avatar image
Travis Lange asked

PlayFab Multiplayer Servers 2.0 (Thunderhead) game server port never opens?

We are currently using PlayFab Multiplayer Servers 2.0 (Thunderhead). When I call PlayFabMultiplayerAPI.RequestMultiplayerServer, the server is created in Thunderhead correctly. I then get this response back:

{
    "ConnectedPlayers": [],
    "FQDN": "dnsa2c7d311-3784-44fa-b27e-1555bde53321-azurebatch-cloudservice.eastus.cloudapp.azure.com",
    "IPV4Address": "40.117.197.88",
    "LastStateTransitionTime": "2019-02-10T01:50:09.409Z",
    "Ports": [
        {
            "Name": "game_port",
            "Num": 30100,
            "Protocol": 0
        }
    ],
    "Region": 5,
    "ServerId": "b536a3a6974802411da47c0a09130e615f59e12f202cac2c219a5c9b8e4d7510",
    "SessionId": "c03b9f6a-a392-4e72-82c5-655ed6be4395",
    "State": "Active",
    "VmId": "xcloudeus4u4yz1807lox:EastUs:fb121f90-a39d-45df-b79c-676a1d3d6694:tvmps_99ba0117da8067c2ec93ab4dbb060a23db82f300d17643d1180e4116b37fb873_d",
    "Request": {
        "BuildId": "710538d8-8fbd-4964-9bca-8ae02bde771b",
        "InitialPlayers": null,
        "PreferredRegions": [
            5
        ],
        "SessionCookie": null,
        "SessionId": "c03b9f6a-a392-4e72-82c5-655ed6be4395"
    },
    "CustomData": null
}

The problem is, port 30100 is closed when I try to connect to it. At first I thought it was a firewall issue on my end so I turned my firewall off to test. That didn't work. I then used Port Forwarding Tester to check if the port was open and it came back closed. I also checked port 50000 (remote desktop connection / RDP) and it came back as open, verifying that the tool does work and the ip address is correct.

The only thing I can think of is the port might close if a client doesn't connect to it in a set amount of time. We have a test environment where we test our PlayFab API calls and another environment for our game. I'm thinking that its possible the port closes while we switch to our game environment and attempt to connect with the ip address and port (because we take too much time switching).

Edit: We tested connecting as soon as we get the response and it still didn't work. We also used Port Forwarding Tester as soon as we got the response and it still came back as closed. It appears that the port never actually opens and / or nothing is listening to it.

Edit 2: We tested this by locally debugging the docker container as described in the tutorial. It also appears to have the same issue. The NodePort never gets opened and nothing is listening to it. I also turned the firewall off when testing this and it didn't seem to fix anything. We tested with both our custom game server and the game server from gsdkSamples GitHub repo. Still nothing listens on the NodePort.

Any help would be greatly appreciated as we have been trying different things for the past 2 days and have been unable to connect. Thanks.

sdks
26 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Travis Lange avatar image Travis Lange commented ·

As to not keep the question from becoming too long, I'll start putting the things we've tried here in the comments. Anyways, we updated our MockVMAgent to version 0.5. We got some new console output that helps:

etc...
infoinfo: MockPlayFabVmAgent[0]
      game_port (TCP): Local port 56100 mapped to container port 7777
: PlayFabAgent[0]
      Container c98093c0371782bd55587d04ef87a3282f391320bdece48f3ec0fa1c5fabe6e1 start completed.
info: MockPlayFabVmAgent[0]
      Waiting for heartbeats from the game server.....

Standing by
etc.....
Active
etc....

As can be seen, "game_port (TCP): Local port 56100 mapped to container port 7777", so the NodePort appears to me mapped. However, when I run the command "netstat -aon | findstr :56100", there is nothing listening on that port. I also can't connect to it with my client. The firewall is turned off so that isn't the problem. When I run "netstat -aon | findstr :56001", it shows that the MockVMAgent is listening on the correct port and I am getting feedback as to the "CurrentGameState" correctly. And my GameServer.exe is logging that it is running and listening on the "game_port 7777" and is switching to the "Active" state correctly.

0 Likes 0 ·
Travis Lange avatar image Travis Lange commented ·

But I still can't connect to 127.0.0.1:56100

0 Likes 0 ·
Travis Lange avatar image Travis Lange commented ·

Here is the entire console output in case anyone spots something I'm missing:

PS D:\DefaultFolders\Documents\PlayFab\MockAgent\v0.5> ./MockVmAgent.exe
Warning: SessionCookie is not specified.
Mock Agent is listening on port 56001
info: PlayFabAgent[0]
      Starting image pull for: mcr.microsoft.com/playfab/multiplayer:wsc-10.0.17134.285.
info: PlayFabAgent[0]
      Created a container with session host id: 2146976d45d41ef2788aa5f89d437f00ed912d20a7600af51976ce9da4af5ea6
info: MockPlayFabVmAgent[0]
      Creating the configuration file at D:\DefaultFolders\Documents\PlayFab\MockAgentOutput\v0.5\PlayFabVmAgentOutput\2019-02-10T14-18-56\c218548b-678c-4e09-9e29-cf47b80ca5e3c6bbdcb2-3d76-461e-9c33-bf83311f6585WestUs\SH0\gsdkConfig.json
infoinfo: PlayFabAgent[0]
      Container 2146976d45d41ef2788aa5f89d437f00ed912d20a7600af51976ce9da4af5ea6 start completed.
: MockPlayFabVmAgent[0]
      game_port (TCP): Local port 56100 mapped to container port 7777
info: MockPlayFabVmAgent[0]
      Waiting for heartbeats from the game server.....
CurrentGameState: StandingBy
CurrentGameState: StandingBy
etc...
CurrentGameState: Active
CurrentGameState: Active
CurrentGameState: Active
etc...
0 Likes 0 ·
ravarna avatar image ravarna commented ·

Hey @TCROC, can you provide the title and build Id for investigation from the PlayFab side?

0 Likes 0 ·
Travis Lange avatar image Travis Lange ravarna commented ·

@ravarna

Title Name: PlayFabTest

Title Id: 8DF

Build Name: PlayFabTest_4

Build Id: 710538d8-8fbd-4964-9bca-8ae02bde771b

0 Likes 0 ·
ravarna avatar image ravarna ravarna commented ·

We got the information from our logs, we are looking in to it. Your build configuration seems fine. We are checking if the asset folder was zipped correctly (it should be if your local debugging is working). I am guessing your game server is listening on port 7777? Is that a correct assumption?

0 Likes 0 ·
Travis Lange avatar image Travis Lange ravarna commented ·

@ravarna But feel free to try it with a session cookie. I can even zip up our project and send it to you if you want.

1 Like 1 ·
Show more comments
ravarna avatar image ravarna commented ·

@TCROC In that case, can you send over the source too, we can also double check the listening part.

0 Likes 0 ·
Travis Lange avatar image Travis Lange ravarna commented ·

@ravarna Ok so I figured out where I was going wrong with the example build.

//Code that works:
string address = $"http://*:{listeningPort}/";


//Code that doesn't work:
string address = $"http://localhost:{listeningPort}/";

Now to figure out how to get this working in our Unity build and where we are going wrong with it.

1 Like 1 ·
Travis Lange avatar image Travis Lange ravarna commented ·

@ravarna I just sent the source code :)

0 Likes 0 ·
Travis Lange avatar image
Travis Lange answered

After spending about a week on this, and getting phenomenal support from @ravarna and the rest of the PlayFab Thunderhead team (idk their forum usernames so I can't tag them) we managed to get a Unity build working with the Thunderhead servers and the NuGet GSDK. They asked me to provide them with some feedback on my experience, so I outlined my experience, some suggestions, and the challenges I faced as well as how I solved them in this attached pdf: playfab-experience.pdf. I hope this pdf helps anyone who runs into similar challenges as well as helps PlayFab in further development. Again, the support was phenomenal and thank you very much to everyone who helped.


12 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brandon@uprootstudios.com avatar image brandon@uprootstudios.com commented ·

Did you have any issues with JSON deserialization when getting the configuration settings?

0 Likes 0 ·
Travis Lange avatar image Travis Lange brandon@uprootstudios.com commented ·

I didn't have any issues. My issue was setting it to TCP when I was actually using UDP. I was switching between UNet and Mirror. UNet used UDP and Mirror used TCP (by default). I didn't realize when switching between the frameworks. I thought they both used TCP.

0 Likes 0 ·
brandon@uprootstudios.com avatar image brandon@uprootstudios.com Travis Lange commented ·

Gotcha, we currently have an issue where our server build fails to deserialize the GSDK Config when using IL2CPP, and have only been able to get it to work using the Mono backend. Is your server build using Mono?

0 Likes 0 ·
Show more comments
Wanchai Khonthai avatar image Wanchai Khonthai commented ·

Hello, I'm trying to integrate GSDK in Unity. I've tested it with MockVmAgent. My problem is that MockVmAgent didn't receive any heartbeat from game server. My game server code is very simple. I just copied some code from gsdkSample. https://pastebin.com/Xm4Jdba8

I really don't know why my game server didn't send hearbeat to MockVmAgent. This is GSDK log. https://pastebin.com/i1PGPGQq

You can see that the log stopped before GameserverSDK.ReadyForPlayers() I'm using Unity 2019.1.2f1 Which Unity and GSDK version are you using?

0 Likes 0 ·
Travis Lange avatar image Travis Lange Wanchai Khonthai commented ·

Hey @Wanchai Khonthai. Your code looks fine. Could you open this up in a new question and include the following information:

  1. The stuff you have already provided in this comment.
  2. Your MultiplayerSettings.json file.
  3. And just confirm that the script is attached and enabled on an active game object in the scene. (This might sound silly, but believe me I've made this mistake myself and seen a lot of people get there question answered for simple things like this. Kinda the game dev version of "Did you try turning it on and off?" lol).
  4. Don't forget to @me and @Brandon Phillips so we get notifications.
1 Like 1 ·
Wanchai Khonthai avatar image Wanchai Khonthai Travis Lange commented ·

@TCROC @Brandon Phillips

Thank you for trying to help. But for an unknown reason, it's working now. My game server properly sends a heartbeat to MockVmAgent. I seriously don't know what happened here. After I restarted window and had a window update today. I ran the same command again and It just worked! -_-*

1 Like 1 ·
Show more comments
brandon@uprootstudios.com avatar image brandon@uprootstudios.com Wanchai Khonthai commented ·

Try putting the GameserverSDK.ReadyForPlayers() check in Update or in another function that runs frequently, like so:

void Update() {
    if (GameserverSDK.ReadyForPlayers()) {
       //
    } else {
       //
    }
}

I think this is what solved it for us.

0 Likes 0 ·
David Rochin avatar image David Rochin commented ·

@TCROC This was very useful, thank you very much.

0 Likes 0 ·
jan-halamicek avatar image
jan-halamicek answered

Just want to tell everyone we have also made it to work with Unity. Now we have Unity game server running on Playfab Multiplayer 2.0 servers and was able to connect from Unity clients! Thanks everyone in this thread for much needed info! The PDF @TCROC helped tremendously!

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Garry Clark avatar image Garry Clark commented ·

Is there an actual release date for Unity and thunderhead though? I thought they were going to release some form of this back in January 2019 and here we are going into January 2020 and still no official support.

I had my Unity server working with the Game Server SDK and now it is broken for some unknown reason. I keep getting a JSON error when executing config = GameserverSDK.getConfigSettings();

0 Likes 0 ·
Garry Clark avatar image Garry Clark Garry Clark commented ·

Should also note i am also seeing the same JSON error in the WinRunnerSample now as well. Did something change recently?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.