#Fetch Remote Config from Cloud Code called from Multiplay

1 messages · Page 1 of 1 (latest)

ashen pike
#

Hi all, I want to configure shared configuration variables for my multiplayer game.
I am using dedicated game server hosting (Multiplay), which calls a Cloud Code module endpoint. The cloud code module endpoint then calls Remote Config to fetch the current configuration for game configuration variables.
The reason why I want to do it this way is, that the game server and the players share the configuration.

I have the use case of computing elo scores after a match in cloud code. Also I need to show elo scores according to server-side business logic (in cloud code) to the players during gameplay.

Is this conceptional a bad thing?

I am asking because I couldn't find out how to fetch the remote config from within cloud save, if the request originates from a dedicated server context, and not a player context.
This means that the cloud code module does not have an AccessToken but only a ServiceToken in such context.

Is it correct that RemoteConfig is not supposed to be called in a service account context, like a dedicated game server in multiplay?
What would be a proper approach, assuming mine is wrong?

I am currently using the following, which does not work:
ServerAuthenticationService.Instance.SignInWithServiceAccountAsync - to sign in on the dedicated game server
Cloud Code services API (https://cloud-code.services.api.unity.com/v1) - to call the cloud code module endpoints with a service account
IRemoteConfigSettingsApi - within cloud code, to fetch the remote config -> this is not possible as it requires an AccessToken and I only have a ServiceToken coming from my service account

Best

lucid wolf
#

You should be able to call a Cloud Code function from the server.

ashen pike
#

I can call the cloud code function from within the multiplay server, that is not the problem

#

The problem is in the cloud code execution, when it tries to fetch the remote config

#

I think I had wrong intuition when I read the docs in the past. It seems that remote config is only intended to serve player specific experiences (configurations, and the overrides). My use case with the dedicated server does not directly follow that approach, but needs a service account to authenticate and then do its requests. I probably need to switch using cloud save

lucid wolf
#

Cloud Save should work as well. But you should be able to use the admin client in cloud code to fetch the Remote Config.

ashen pike
#

With admin client you refer to using the REST API?

golden edge
#

I think evilotaku is referring to the IAdminApiClient in Cloud Code. I just took a look and there does not seem to be Remote Config support in that client. Quick reminder that IAdminApiClient should not be used for player-scale operations as the rate limits are much lower than the IGameApiClient

lucid wolf
golden edge
#

Unfortunately that's not the case, at least currently. I'll chat with the people involved with the apis package and cloud code to see if we can get better parity there.

#

@ashen pike for your use-case I can currently see two options. The first is as you described, to store information in cloud save and access that from your game server. The other option would be to use the REST API, though as I mentioned above you may hit rate limit issues at scale.

ashen pike
#

Thanks to both of you for the fast and helpful answers🙏🏻 I will make my thoughts about it. I will probably go for cloud save, as I have bad experience when rate limits start to hit and you did not proactively monitor reaching them 😅 After I'll have tested the new approach, I will post here the result and then mark this as solved.

ashen pike
#

I got rid of remote config.

For the cloud code part, I am using now cloud save instead of remote config.

For the player and server builds, I ended up writing a facade to choose the implementation at compile time, depending on whether the build targets UNITY_SERVER. If so, I use cloud save API with a service account. If not, I use the CloudSaveService.Instance
This allows my implementation of the business logic to stay the same, independent of whether the build targets UNITY_SERVER.

Therefore, the problem is solved and I could also verify that all combinations are working now.

fringe lantern
#

Interesting setup — sharing config between server and clients makes total sense. But I’m also wondering how others are handling this, because Remote Config seems pretty locked to player access tokens rather than service tokens. I haven’t seen anyone successfully pull RC from a Multiplay service-account context yet.

Curious how other teams are solving shared config: are folks routing this through Cloud Code/CCD/a custom JSON endpoint, or using something more client-side and instant? Some solutions look pretty heavy.

lucid wolf
fringe lantern