Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question How to Connect a Client to Unity Game Server Hosting Online?

Discussion in 'Game Server Hosting' started by donbonbon, Mar 27, 2024.

  1. donbonbon

    donbonbon

    Joined:
    May 28, 2023
    Posts:
    29
    'm currently facing a challenge in connecting a client to a game hosted on Unity's Game Server Hosting (Multiplay) over the internet. I've managed to create a dedicated server build and successfully uploaded it to Multiplay. The allocation test was positive, and I can connect to the game server locally using the Unity Editor. However, transitioning this process to work online has been confusing and unsuccessful so far.

    Here's a summary of what I've tried and the obstacles I've encountered:

    1. Direct Connection Attempt: Attempting to connect to the game server using its address and port directly hasn't worked. It seems that some form of Unity-specific client input is necessary. Do I need to create a specific client build for this purpose?

    2. WebGL Build: I've also experimented with a WebGL build but failed to establish any connection to the server. I haven't configured any WebSockets, which might be the issue if the dedicated server build doesn't set these up by default.

    3. Linux Build: Considering the server's Linux environment, I attempted a Linux build for the client. While this theoretically matches the server's environment, I couldn't make an online connection, even after bypassing graphics dependencies using the -batchmode and -nographics flags. My command line was as follows:


      Code (CSharp):
      1. ./executable.x86_64 -batchmode -nographics -logFile ./logFile.txt -ip "server-game-address" -port "9000"
    I'm at a loss for how to proceed and would greatly appreciate any guidance, advice, or resources you could share. How can I successfully connect a client to our game server hosted online through Unity's Game Server Hosting?

    Thank you in advance for your help!
     
  2. slickgotchi

    slickgotchi

    Joined:
    Jun 26, 2022
    Posts:
    28
    Maybe a bit late but basically you need to start by using the Game server lifecycle API
    Unity Services Web API docs
    Do the following from your client app:
    1. Create your own UUID to assign to an allocation
    2. Queue an allocation with a POST request
    3. Poll with Get allocation request (using your UUID you made)
    4. Once you receive back a valid allocation use its gamePort and ipv4 for your client to connect