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 What is the minimum to convert a Unity server working locally to Unity Game Server Hosting?

Discussion in 'Game Server Hosting' started by shu-yan, Feb 21, 2024.

  1. shu-yan

    shu-yan

    Joined:
    Dec 1, 2022
    Posts:
    8
    I am asking because from the Unity's tutorials on Game Server hosting, it seems the minimum is just to add the Multiplay SDK package to your project and link the Unity Cloud project ID. Then one can upload the files and it would be ready (at least for Test allocation)

    I did just that but my client cannot connect to the Test allocation server, and I also notice that the server would just terminate itself very soon.

    I am seeing these error in the Test Allocations Dashboard:

    Server having issues (Query didn't respond or responded incorrectly [DOWN]) for 61 seconds (Restarted 0 time(s))
    Allocated server had issues (Query didn't respond or responded incorrectly [DOWN]), stopping server and deallocating

    I am wondering is my sever unable to connect to the server (when it was running briefly) related to no SQP handling being implemented? Posts like this one ( https://forum.unity.com/threads/all...own-stopping-server-and-deallocating.1375152/ ) seems to suggest that one need to add code to at least answer readiness SQP queries from Unity Game Server Hosting?

    However, the way to handle those SQP as given in https://docs.unity.com/ugs/en-us/manual/game-server-hosting/manual/sdk/game-server-sdk-for-unity are quite different from the way the MatchplaySample code ( https://github.com/Unity-Technologies/com.unity.services.samples.matchplay ) handles it. For one, I failed to search the method ReadyServerForPlayersAsync() suggested in the SDK manual being called in the MatchplaySample code.

    Since one cannot test OnAllocate and OnDeallocate events when running locally, I followed https://docs.unity.com/ugs/en-us/manual/game-server-hosting/manual/concepts/server-json to add a server.json file when running locally. My server code does read in the config successfully, but when it tried to call the ReadyServerForPlayersAsync() method, I got a HTTPexception:

    HttpException: (0) Cannot connect to destination host
    Unity.Services.Multiplay.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.Multiplay.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) (at ./Library/PackageCache/com.unity.services.multiplay@1.1.1/Runtime/Http/ResponseHandler.cs:121)

    In the server,json, I have set the following
    "ip": "127.0.0.1",
    "port": "9000",

    And my client can still connect to the server successfully at 127.0.0.1:9000 after seeing that HttpException message in the console.

    I cannot find any documentation stating why the SDK is attempting to make a connection to the IP address specified in the server.json (or may be it is suppose to be the IP address of something else!!?) And then I saw from the server log that it was actually trying to connect to:
    Curl error 7: Failed to connect to 127.0.0.1 port 8086 after 0 ms: Error

    I cannot find in my codebase where the port number 8086 come from, but in the MatchplaySample, that was the PayloadProxyUrl

    At the moment, I am at a lost on how to proceed to get my server working as a single instance on Unity Game Server Hosting that would listen to my client in a single port. Am I on the correct path to try to get the SQP handling working first, or should the server be accepting connection on Unity Game Server Hosting anyway without SQP handing setup and I should dig into that instead?