Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to handle network timeout and retry

Discussion in 'Addressables' started by kactus223, Feb 18, 2021.

  1. kactus223

    kactus223

    Joined:
    May 20, 2014
    Posts:
    35
    I want to load a scene from a remote bundle. In a good case scenario, it works perfectly, but when the internet is unable and the download timeout, I want to display an error popup with a retry button, so that players can try downloading that scene again. The problem is I can't find a way to detect if the download is failed. The Addressables system just throws a bunch of exceptions and hang.

    Code (CSharp):
    1. Exception encountered in operation Resource<IAssetBundleResource>(timessquare_scenes_all.bundle), status=Failed, result= : RemoteAssetBundleProvider unable to load from url https://cdn.mnm.mydomain.com/timessquare_scenes_all.bundle, result='Request timeout'.
    2. UnityEngine.AsyncOperation:InvokeCompletionEvent() (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/AsyncOperation.cs:21)
    Code (CSharp):
    1. Scene 'Intro01.unity' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.ResourceManagement.ResourceProviders.SceneProvider+SceneOp.InternalLoadScene (UnityEngine.ResourceManagement.ResourceLocations.IResourceLocation location, System.Boolean loadingFromBundle, UnityEngine.SceneManagement.LoadSceneMode loadMode, System.Boolean activateOnLoad, System.Int32 priority) (at Library/PackageCache/com.unity.addressables@1.16.1/Runtime/ResourceManager/ResourceProviders/SceneProvider.cs:78)
    3. UnityEngine.ResourceManagement.ResourceProviders.SceneProvider+SceneOp.Execute () (at Library/PackageCache/com.unity.addressables@1.16.1/Runtime/ResourceManager/ResourceProviders/SceneProvider.cs:68)
    4. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].InvokeExecute () (at Library/PackageCache/com.unity.addressables@1.16.1/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:484)
    5. UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1[TObject].<.ctor>b__37_0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle o) (at Library/PackageCache/com.unity.addressables@1.16.1/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:120)
    6. DelegateList`1[T].Invoke (T res) (at Library/PackageCache/com.unity.addressables@1.16.1/Runtime/ResourceManager/Util/DelegateList.cs:69)
    7. UnityEngine.Debug:LogException(Exception)
    8. DelegateList`1:Invoke(AsyncOperationHandle) (at Library/PackageCache/com.unity.addressables@1.16.1/Runtime/ResourceManager/Util/DelegateList.cs:73)
    9. UnityEngine.ResourceManagement.ResourceManager:Update(Single)
    10. MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.16.1/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:26)
     
  2. kactus223

    kactus223

    Joined:
    May 20, 2014
    Posts:
    35
  3. Raghavendra

    Raghavendra

    Joined:
    Mar 14, 2014
    Posts:
    52
    I compare the previously downloaded bytes with the current downloaded bytes. If they are the same for 20 secs then i show a retry popup. But i am sure there must be some proper way to handle this. Anyone?