question

projecthyperdrive avatar image
projecthyperdrive asked

Specify Game Port Multiplayer Servers 2.0

I am having trouble connecting my clients to a running server when they successfully complete a matchmaking ticket. I have searched around and am still quite confused as to how to specify and receive the game port that my server must listen on. When creating a new build, I have listed 7777 as both TCP and UDP game ports as follows:

* Am I correct in assuming that PlayFab will now forward port 7777 for TCP/UDP and I can tell my server to listen on that port? If not, is the value of game_port given to my server through command line args?

* When my clients receive a match through matchmaking, will this same game_port value be sent through to them?

* (Side Question): Is there a way to manually shutdown an active game server through the GameManager or do I need to remote in to shut it down?

ports.png (9.9 KiB)
10 |1200

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

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

>> Am I correct in assuming that PlayFab will now forward port 7777 for TCP/UDP and I can tell my server to listen on that port? If not, is the value of game_port given to my server through command line args?

It’s the latter. The value of “game_port” is given to the server executable through command line args. You can navigate to PlayFab GSDK sample GitHub page to check the c# and Unity gsdk samples. You need to ensure “ListeningPortKey”’s value in line 21 of this page is the same as the port name in GameManager.

>> When my clients receive a match through matchmaking, will this same game_port value be sent through to them?

No, this port is the listening port that used to let PlayFab can manage the server executable. clients will be assigned the temporary IP address and port number for connecting the server. When clients connect to the server, they actually connect to the server sessions. You can check the doc Basics of a PlayFab game server for some basic info of PlayFab game sever.

>> (Side Question): Is there a way to manually shutdown an active game server through the GameManager or do I need to remote in to shut it down?

PlayFab API ShutdownMultiplayerServer can be used to shut down the active server sessions. Generally, if you integrate GSDK with the custom server correctly, PlayFab will shut down the server session after the match overs. You can check this doc Integrating game servers with the PlayFab game server SDK (GSDK) for the knowledge about how to integrating game servers with the GSDK.

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.

projecthyperdrive avatar image projecthyperdrive commented ·

@Sarah Zhang Hi Sarah I am still having a pretty hard time getting my Server to listen on the correct port. I am currently processing the -game_port command line arg server-side and listening on this port value. Is this correct? My clients are given port 30000 to connect on and are not able to make a connection.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang projecthyperdrive commented ·

>> I am currently processing the -game_port command line arg server-side and listening on this port value. Is this correct?

Could you please tell us have you deployed the server build on the PlayFab or are you locally debugging the sever?

If you have deployed it, generally, game developers don’t have to process the command line by themselves, you just need to keep that const string ListeningPortKey = "game_port"; when the port [Name] in the [GameManager] is “game_port”. In other words, it the port [Name] in the [GameManager] is “Game_Port”, please let ListeningPortKey = Game_Port.

>> My clients are given port 30000 to connect on and are not able to make a connection.

If you have deployed the server, clients should connect the IP addresses and Ports that in the response of API RequestMultiplayerServer. If you have deployed the server and use PlayFab Matchmaking with the custom servers, clients can connect the IP addresses and Ports that in the response of API GetMatch. The ports are assigned by PlayFab, not designated by developers.

0 Likes 0 ·
Daniel avatar image Daniel Sarah Zhang commented ·

Nice, but I am doing exactly the same but it does not work for me.
When trying to join using websockets, the client gets disconnected with the " Request Finished with Error Exception: TCP Stream closed unexpectedly by the remote server at BestHTTP.WebSocket.Frames.WebSocketFrameReader.ReadByte (System.IO.Stream stream) " reason.

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.