Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Remote Config does not work in WebGL build

Discussion in 'Unity Remote Config' started by alvaris924, Aug 25, 2021.

  1. alvaris924

    alvaris924

    Joined:
    Aug 3, 2011
    Posts:
    35
    So the integration of Remote Config has been a bumpy ride, but I am finally close to full solution.

    The latest issue is that I can get the values from Remote Config service when I'm in Editor and Windows Standalone build, but I get empty values when I'm in WebGL build, just like what an user experienced in this post (https://forum.unity.com/threads/rem...ktop-but-doesnt-work-for-webgl-build.1024762/).

    My code is very standard, which is displayed below:


    Code (CSharp):
    1. void ApplyRemoteSettings(ConfigResponse configResponse) {
    2.         // Conditionally update settings, depending on the response's origin:
    3.         switch (configResponse.requestOrigin) {
    4.  
    5.             case ConfigOrigin.Default:
    6.                 Debug.Log("No settings loaded this session; using default values.");
    7.                 break;
    8.  
    9.             case ConfigOrigin.Cached:
    10.                 Debug.Log("No settings loaded this session; using cached values from a previous session.");
    11.                 break;
    12.  
    13.             case ConfigOrigin.Remote:
    14.  
    15.                 Debug.Log("New settings loaded this session; update values accordingly.");
    16.  
    17.                string latestInGameNews = ConfigManager.appConfig.GetString(InGameNewsConfig);
    18.  
    19.                 Debug.Log("Latest InGameNews: " + latestInGameNews);
    20.  
    21.  
    22.                 break;
    23.         }
    In WebGL build, I can get the "New settings loaded this session; update values accordingly." message, which should indicate I did indeed get the response from server.

    upload_2021-8-25_17-43-12.png

    However, when I tried to call the InGameNewsConfig's value, it returns empty value.

    This only happens in WebGL build, and as mentioned I did get the response from Editor and Windows build, so I don't think I need to do anything related to Charles or David or whatever utility :D.

    What could be the issue? I'm using Unity 2020.3.2f1, and below is my Player Settings:

    upload_2021-8-25_17-43-57.png

    And further below is my Remote Config package detail:

    upload_2021-8-25_17-44-52.png

    Thanks!
     
  2. alvaris924

    alvaris924

    Joined:
    Aug 3, 2011
    Posts:
    35
    As extra info, I tried to manually call:

    Code (CSharp):
    1. ConfigManager.FetchConfigs<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
    and

    Code (CSharp):
    1. string latestInGameNews = ConfigManager.appConfig.GetString(InGameNewsConfig);
    2.  
    3.         Debug.Log("Latest InGameNews: " + latestInGameNews);
    string latestInGameNews = ConfigManager.appConfig.GetString(InGameNewsConfig);
    ConsoleProDebugger.Log_Focus("Latest InGameNews: " + latestInGameNews);

    after I'm like 5 mins into the build, still nothing happens.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @alvaris924 I had tested WebGL previously, and it worked. Which web server are you hosting on, or are you just using Build and Run from within Unity? A Charles Proxy capture may help to understand what is going on, as you mentioned.
     
  4. alvaris924

    alvaris924

    Joined:
    Aug 3, 2011
    Posts:
    35
    Many thanks for your reply!

    I hosted the build on Y8's test server (https://storage-direct.y8.com/), and after few checks today I realized that sometimes I can get the correct values from Remote Config server.

    Whenever I can't get the values from server, I will get error below:

    upload_2021-8-25_21-42-40.png

    Tested in both Chrome and Firefox, and this error can happen to any browser periodically.

    Tested with VPN and without VPN, and made sure VPN wasn't the issue.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Looks like a bad network connection if it works sometimes. A Charles Proxy capture may provide more info.
     
  6. alvaris924

    alvaris924

    Joined:
    Aug 3, 2011
    Posts:
    35
    Okay, so I did the Charles Proxy, and though I'm not sure if Remote Config is related to 'https://config.uca.cloud.unity3d.com', attached below is its error report:

    upload_2021-8-27_14-28-56.png

    it says Charles failed to connect to the remote host, but it is not possible that my Internet connection is the issue, since my game will need to connect to Photon Network and Y8 API, before Remote Config's connection is requested.

    Also after the error, I can play multiplayer game through Photon and view Y8's leaderboard without connection issue at all, so I'm curious about the true cause that generates this disconnection error :eek:.

    In case you need Charles' log file, kindly download it from link below:

    Code (CSharp):
    1. https://drive.google.com/file/d/1sKeLzu8tfjk3gQNmtLyl6MLR12gb71mJ/view
    You can try out the WebGL build from link below:

    Code (CSharp):
    1. https://storage-direct.y8.com/atk9999studios/html5/index.html
    My further thanks in advance!
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You mentioned it sometimes works, do you see that in your Charles capture also? Can you ping config.uca.cloud.unity3d.com ? How does it behave when you do Build and Run directly from Unity and host the project locally?