question

Kevin Beqo avatar image
Kevin Beqo asked

UE4 - Matchmaking and Connection to Server

Hello,

I have implemented PlayFab's Matchmaking system and have deployed a build on a PlayFab server.
I use server allocation in matchmaking and my thought process is to connect clients using the IP:PORT returned in the response of the GetMatch request.

Matchmaking is implemented client-side and is functional (via BP) but my issue is that I cannot connect to the server via the returned IP:PORT. The server does become Active after a match is found.

By "cannot connect", I mean that there is a connection timeout. I am not experienced in this; I did a ping to the server's IP but I still get a timeout. (not sure if related)


Checked a lot of posts but have not found a solution yet so sorry if I have missed something.

Matchmakingunreal
1 comment
10 |1200

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

Benjamin Ikes avatar image Benjamin Ikes commented ·

Hey I have the same problem in Unity3D will keep you updated if I find a solution

1 Like 1 ·
Kevin Beqo avatar image
Kevin Beqo answered

Ok I managed to fix it.

Assuming you have tested successfully using the LocalMultiplayerAgent:

I had configured my build to run as a Windows Process; and unfortunately I still don't have a fix for this but I created a new build as a Windows Container.

And basically that was it, I could connect in-game using a basic open IP:PORT. What I noticed though, was that when I chose Windows Container, a section of Ports was opened in the build configuration form. So I could input there the port name AND number (which was missing in the Windows Process option). Most likely this made the difference since afterwards the mapping of the 30000 (first layer port) could be done to the actual game port (in UE4 case 7777)

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.

Dimitris Gkanatsios avatar image Dimitris Gkanatsios commented ·

When on process mode, you need to get the *local* Port via GSDK in this way MpsSamples/Program.cs at master PlayFab/MpsSamples (github.com) and *not* open 7777 directly. This is because you may have >=1 processes running on the same VM. If all of them try to open 7777, port collision will occur. So, to solve this problem, PlayFab gives you a port that you can use locally to open your server.

Be aware that this port will almost certainly be different than the public port - use it only to open your local server and for no other purpose.

The above is only valid on process mode. On container mode, each container uses its own network namespace, so more than one containers can open and use port 7777.

Hope this helps

1 Like 1 ·
Kevin Beqo avatar image Kevin Beqo Dimitris Gkanatsios commented ·

Many thanks for the explanation! It is clearer now.
I was not familiar with containers so I went with the process approach.

For the moment I will keep the container mode though since I have not researched pros/cons between the two.

1 Like 1 ·
Gosen Gao avatar image
Gosen Gao answered

I have done a quick test in my server build and confirmed that the ping does time out, although the server is able to connect. You can try to deploy your server build locally by following -- Locally debugging game servers and integration with PlayFab to confirm the cause of the issue.

Just in case, PlayFab multiplayer game servers require integration with PlayFab Game Server SDK (GSDK) which helps you connect your game server to the PlayFab agent installed on the VM. Please make sure that you have integrated with the correct GSDK.

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.

Kevin Beqo avatar image Kevin Beqo commented ·

Thank you for the quick reply.

I have run completed the integration with GSDK and ran the verification steps successfully as noted here: Locally debugging game servers and integration with PlayFab - PlayFab | Microsoft Docs

What I have not tried though is this step: Locally debugging game servers and integration with PlayFab - PlayFab | Microsoft Docs
so I will give that a try after work today and let you know whether I can connect locally or not.

When you say "the server is able to connect", you mean a client is able to connect to the Active server? Just want to clarify that the server does become Active and when I connect to the VM, I see the game process is running in the background.

0 Likes 0 ·
Kevin Beqo avatar image Kevin Beqo commented ·

An update as per my below message. I tried again the LocalMultiplayerAgent by doing the "Test your connection..." step and it connects ok locally.

Will continue some of the server-side debugging steps mentioned by @Dimitris Gkanatsios
Thanks.

0 Likes 0 ·
Dimitris Gkanatsios avatar image
Dimitris Gkanatsios answered

First of all, ping is disabled on Azure for security purposes. You should check if the port is open and the server is listening to requests. Check some debugging tips here MpsSamples/Debugging.md at master PlayFab/MpsSamples (github.com) and you should definitely try using the LocalMultiplayerAgent as well.

5 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.

ravarna avatar image ravarna commented ·

@Kevin Beqo, since you are logged into the VM and running netstat, have you tried checking the resource monitor for networking to see what's the exact port being used your process? Are you using a unity game? When you are running as a process, it is best that the game server listens on the port given by the GSDK (https://github.com/PlayFab/gsdk/blob/f6ced2bbc1f5701dccb6b8d2b4c4d10d3b28ce62/csharp/GSDK_CSharp_Standard/GameserverSDK.cs#L75)
Otherwise, your server is listening on port X while the traffic from clients go to port Y. Can you share your titleId?

1 Like 1 ·
Kevin Beqo avatar image Kevin Beqo ravarna commented ·

Thanks for the link. I have switched to container approach and as my answer mentions, it is working as expected. Most likely I have had issues with understanding how port mapping works with the Windows Process method.

Will remember this info for next time I guess :) Thank you!

0 Likes 0 ·
Kevin Beqo avatar image Kevin Beqo commented ·

Hi, thanks for answering.

Please correct me if I did something wrong below:

I am running my game build on windows process, so I used the "netstat -aon" command to check the ports. My game port is 30000 as in pic below.

I did not see this port number at all in the list returned from netstat. Although I got a bit confused with the port mapping so I thought maybe this is ok since the VM might use some other port?



In addition I did run the LocalMultiplayerAgent, as I mentioned in the comment above; I could connect successfully with correct heartbeats, status updates etc.

0 Likes 0 ·
Kevin Beqo avatar image Kevin Beqo commented ·

@Dimitris Gkanatsiosand a partial result from netstat in the second attachment

0 Likes 0 ·
Kevin Beqo avatar image Kevin Beqo commented ·

Sorry for multiple comments. Just wanted to add that I will retry with another build, on a Windows Container instead.

0 Likes 0 ·
Dimitris Gkanatsios avatar image
Dimitris Gkanatsios answered

Also please check this video at around minute 22, where we explain port mapping on MPS https://www.youtube.com/watch?v=kj2TcMlvWgk

3 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.

Benjamin Ikes avatar image Benjamin Ikes commented ·

Hey also have the same problem that clients will not connect but mirror shows they do for a short time.... I am on unity dont know what to do been trying for days

0 Likes 0 ·
Kevin Beqo avatar image Kevin Beqo Benjamin Ikes commented ·

Check to see if my answer below helps you bro.

0 Likes 0 ·
Dimitris Gkanatsios avatar image Dimitris Gkanatsios Benjamin Ikes commented ·

any chance the server is crashing after people connect?

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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]