Remote Config throwing error in offline mode.

Hey,

I was testing remote config and decided to check how your code works when I turn internet off. I expected the FetchCompleted event to be triggered and have a response status of Failed, with a config origin of Default / Cached.

But it threw an error : WebRequestException: Cannot connect to destination host
After some digging I found out that the issue is in ConfigManagerImpl on line 338 :

public async Task<RuntimeConfig> FetchConfigsAsync(object userAttributes, object appAttributes)
{
   return await FetchConfigsAsync("settings", userAttributes, appAttributes, null);
}

In this method there is a line (line 286) that’s doing : var response = await request.SendWebRequest(); and this is where the game dies.

I assume this is not the intended behavior. Any help on this?

Update : Sometimes it fails, sometimes it hangs. So using offline mode with this is basically impossible. Anyone at Unity, please?

Hey @alex11paulescu thanks for pointing to this issue!
While we tested our test app for the case of RC fetch without the internet, we could not reproduce this issue you encountered.
(Tested for standalone and Android)

It seems that this issue is related to the way unity web request (UWR) works, and more devs experienced issues with UWR similar to yours:

For the RC, we use the timeout of 10 seconds.
As this is a relatively long time before UnityWebRequest aborts I am not sure if adjusting this timeout would help,
but timeout could be overwritten before sending the request such as:

request.timeout = 1;

Also, within this post , setting

UWR.useHttpContinue = false;

according to UWR docs allowed them to recover from the same issue.

Furthermore, based on this forum post
this issue could be related to some kind of UWR caching with an interesting timestamping URL solution to avoid UWR caching at the bottom of the post


What we could immediately try is to add

request.useHttpContinue = false;

above the line you mentioned and see if this resolves the UWR caching issue when no internet.

Please let us know if that helps, and if not, we need to consider corresponding steps on the RC side to alleviate this issue.

We too have been finding this same offline behaviour using Unity 6000.2.0b12 and RC package 4.1.1 (runtime 4.0.2). Creating a modded version of RC runtime with the suggested useHttpContinue = false workaround didn’t change the behaviour; the app still soft locks in FetchConfigsAsync when offline.

As a workaround, we were not registering a handler for FetchCompleted and instead wrapping the FetchConfigsAsync in a try/catch block and then calling the handling function directly passing in the RemoteConfigService.Instance.appConfig.origin. This meant we handled any errors from the Fetch (e.g. web request failing due to no internet) and applied the default/cached config anyway, rather than getting stuck in the async await. The inspiration for this approach came from your comment here @vd_unity

As an aside, using this workaround we noticed that the origin is “remote” which was presumably because the config has been initialised from the cached file (where we see “requestOrigin”:2). It also seemed like a fairly un-ideal solution because we’re by-passing state set by the RC response.

As an alternative we modified the RC runtime package by wrapping the call to SendWebRequest in a try/catch block, then handled the catch using the same code in the if (response.IsHttpError || response.IsNetworkError) condition. This worked, allowing us to register the handler as intended but now requires us to maintain a custom RC runtime package :frowning: Any info on when this might get addressed in a future release? TIA

1 Like