question

szulmarek avatar image
szulmarek asked

Multiplayer java server healthcheck problem

Hello,

I want to create a simple running multiplayer server with Java. I've been following the documentation and I've implemented a bare minimum (according to the docs) version of a server. I dockerized it and created a build but it failed. Then I used LocalMultiplayerAgentPublish to debug it and I found the issue. The problem is with healthcheck but it seems to be an internal sdk problem with serializing a healthcheck response. Am I doing something wrong or is it a bug?

The logs:

       GLogging GSDK output to: /data/GameLogs/GSDK_output_20230426_150110.txt
       AException in thread "main" java.lang.ExceptionInInitializerError
       (    at org.example.Main.main(Main.java:90)
       �Caused by: com.microsoft.azure.gaming.GameserverSDKInitializationException: Failed to contact Agent. GSDK failed to initialize.
       P    at com.microsoft.azure.gaming.HeartbeatThread.<init>(HeartbeatThread.java:102)
       K    at com.microsoft.azure.gaming.GameserverSDK.start(GameserverSDK.java:126)
       M    at com.microsoft.azure.gaming.GameserverSDK.<clinit>(GameserverSDK.java:83)
           ... 1 more
       oCaused by: com.github.rholder.retry.RetryException: Retrying failed to complete successfully after 8 attempts.
       <    at com.github.rholder.retry.Retryer.call(Retryer.java:174)
       W    at com.microsoft.azure.gaming.HeartbeatThread.sendHeartbeat(HeartbeatThread.java:263)
       O    at com.microsoft.azure.gaming.HeartbeatThread.<init>(HeartbeatThread.java:98)
           ... 3 more
       �Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.time.LocalDateTime java.time.ZonedDateTime.dateTime accessible: module java.base does not "opens java.time" to unnamed module @45ded7b2
       b    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
       b    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
       L    at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180)
       D    at java.base/java.lang.reflect.Field.setAccessible(Field.java:174)
       u    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:157)
       m    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
       3    at com.google.gson.Gson.getAdapter(Gson.java:423)
       w    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:115)
       u    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:164)
       m    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:100)
       3    at com.google.gson.Gson.getAdapter(Gson.java:423)
       /    at com.google.gson.Gson.toJson(Gson.java:661)
       /    at com.google.gson.Gson.toJson(Gson.java:648)
       /    at com.google.gson.Gson.toJson(Gson.java:603)
       /    at com.google.gson.Gson.toJson(Gson.java:583)
       `    at com.microsoft.azure.gaming.HeartbeatThread.lambda$sendHeartbeat$0(HeartbeatThread.java:275)
       f    at com.github.rholder.retry.AttemptTimeLimiters$NoAttemptTimeLimit.call(AttemptTimeLimiters.java:78)
       <    at com.github.rholder.retry.Retryer.call(Retryer.java:160)
           ... 5 more

Server code:

 package org.example;
    
 import com.microsoft.azure.gaming.GameHostHealth;
 import com.microsoft.azure.gaming.GameserverSDK;
    
 import java.io.IOException;
 import java.time.ZonedDateTime;
    
 public class Main {
    
     public static void main(String[] args) throws IOException {
         GameserverSDK.registerShutdownCallback(Main::onShutdown);
         GameserverSDK.registerMaintenanceCallback(Main::onMaintenanceScheduled);
         GameserverSDK.registerHealthCallback(Main::getGameHealth);
         GameserverSDK.log("Starting server...");
         GameserverSDK.start();
         if (GameserverSDK.readyForPlayers()) {
             GameserverSDK.log("Server ready for players");
         } else {
             GameserverSDK.log("Failed to init the server, exiting");
         }
     }
    
     public static void onShutdown() {
         GameserverSDK.log("Shutdown callback received");
     }
    
     private static void onMaintenanceScheduled(ZonedDateTime time) {
         GameserverSDK.log("Returning maintenance callback on " + time.toString());
     }
    
     private static GameHostHealth getGameHealth() {
         return GameHostHealth.Healthy;
     }
    
 }

Dockerfile:

 FROM openjdk:18
 COPY target/*.jar myserver.jar
 CMD java -jar myserver.jar
multiplayer
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

·
Dimitris-Ilias Gkanatsios avatar image
Dimitris-Ilias Gkanatsios answered

Are you running LocalMultiplayerAgent with the -lcow parameter? What are your settings? The error seems to indicate that the server cannot contact the HTTP server opened by LocalMultiplayerAgent https://github.com/PlayFab/gsdk/blob/2a26715f7024575dc6030bbf318250e1852b33ec/java/gameserverSDK/src/main/java/com/microsoft/azure/gaming/HeartbeatThread.java#L91

10 |1200

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

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.