Remote Config throwing error in offline mode.


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.