Hi Everyone, I am trying to upload some data on the cloud right after the user is successfully signed in. But I am uploading at the same time without waiting, for 21 values.
Example -
public void InitDataOnCloudForFirstLaunch()
{
DownloadPlayerDataFromoCloud(key1);
DownloadPlayerDataFromoCloud(key2);
DownloadPlayerDataFromoCloud(key3);
DownloadPlayerDataFromoCloud(key4);
DownloadPlayerDataFromoCloud(key5);
}
Is it because of this ?
How can I solve this, I used a coroutine and gave a small gap of 0.2f sec but is there a better way because it may cause some issues in devices with slow internet or slow processing.
Also I am uploading all the data together at first launch because I was getting an error if I was fetching the value without pushing a value in the cloud.
Please do share some feedback with this issue. Or do let me know how can I optimize this whole code so that I dont face any errors for all kind of devices.
I have linked both the errors bellow.
1st Error -
CloudSaveException: HTTP/1.1 409 Conflict
UnityEngine.Debug:LogError (object)
Unity.Services.CloudSave.CloudSaveApiErrorHandler: PerformTemporaryErrorLogWorkaround (string,string) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Exceptions/CloudSaveAPIErrorHandler.cs:140)
Unity.Services.CloudSave.CloudSaveApiErrorHandler:HandleDeserializationException (Unity.Services.CloudSave.Internal.Http.ResponseDeserializationException) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Exceptions/CloudSaveAPIErrorHandler.cs:78)
Unity.Services.CloudSave.SaveDataInternal/d__4:MoveNext () (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/SaveData.cs:171)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.CloudSave.Internal.Response
1<Unity.Services.CloudSave.Internal.Models.SetItemBatchResponse>>:SetException (System.Exception)
Unity.Services.CloudSave.ApiClient/d__5:MoveNext () (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/ApiClient.cs:57)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.CloudSave.Internal.Response
1<Unity.Services.CloudSave.Internal.Models.SetItemBatchResponse>>:SetException (System.Exception)
Unity.Services.CloudSave.Internal.Apis.Data.DataApiClient/d__11:MoveNext () (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Apis/DataApi.cs:250)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.CloudSave.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudSave.Internal.Http.HttpClientResponse) Unity.Services.CloudSave.Internal.Http.HttpClient/<MakeRequestAsync>d__3:MoveNext () (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/HttpClient.cs:47) System.Runtime.CompilerServices.AsyncTaskMethodBuilder
1<Unity.Services.CloudSave.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudSave.Internal.Http.HttpClientResponse)
Unity.Services.CloudSave.Internal.Http.HttpClient/d__7:MoveNext () (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/HttpClient.cs:138)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1<Unity.Services.CloudSave.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudSave.Internal.Http.HttpClientResponse) Unity.Services.CloudSave.Internal.Http.HttpClient/<>c__DisplayClass7_0/<<CreateWebRequestAsync>b__0>d:MoveNext () (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/HttpClient.cs:135) System.Threading.Tasks.TaskCompletionSource
1<Unity.Services.CloudSave.Internal.Http.HttpClientResponse>:SetResult (Unity.Services.CloudSave.Internal.Http.HttpClientResponse)
Unity.Services.CloudSave.Internal.Http.UnityWebRequestHelpers/<>c__DisplayClass0_0:b__0 (UnityEngine.AsyncOperation) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/UnityWebRequestHelpers.cs:34)
UnityEngine.AsyncOperation:InvokeCompletionEvent ()
2nd Error-
JsonSerializationException: Required property ‘data’ not found in JSON. Path ‘’, line 1, position 218.
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EndProcessProperty (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, System.Int32 initialDepth, Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.Serialization.JsonSerializerInternalReader+PropertyPresence presence, System.Boolean setDefaultValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2587)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.Serialization.ObjectConstructor1[T] creator, System.String id) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2168) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract objectContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id, System.Boolean& createdFromNonDefaultCreator) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:2318) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:493) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:309) Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:202) Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/JsonSerializer.cs:904) Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/JsonSerializer.cs:883) Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:831) Unity.Services.CloudSave.Internal.Http.ResponseHandler.TryDeserializeResponse (Unity.Services.CloudSave.Internal.Http.HttpClientResponse response, System.Type type) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/ResponseHandler.cs:66) Unity.Services.CloudSave.Internal.Http.ResponseHandler.CreateHttpException (Unity.Services.CloudSave.Internal.Http.HttpClientResponse response, System.Type responseType) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/ResponseHandler.cs:149) Rethrow as ResponseDeserializationException: Required property 'data' not found in JSON. Path '', line 1, position 218. Unity.Services.CloudSave.Internal.Http.ResponseHandler.CreateHttpException (Unity.Services.CloudSave.Internal.Http.HttpClientResponse response, System.Type responseType) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/ResponseHandler.cs:172) Unity.Services.CloudSave.Internal.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.CloudSave.Internal.Http.HttpClientResponse response, System.Collections.Generic.Dictionary
2[TKey,TValue] statusCodeToTypeMap) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/ResponseHandler.cs:103)
Unity.Services.CloudSave.Internal.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.CloudSave.Internal.Http.HttpClientResponse response, System.Collections.Generic.Dictionary2[TKey,TValue] statusCodeToTypeMap) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Http/ResponseHandler.cs:186) Unity.Services.CloudSave.Internal.Apis.Data.DataApiClient.SetItemBatchAsync (Unity.Services.CloudSave.Internal.Data.SetItemBatchRequest request, Unity.Services.CloudSave.Internal.Configuration operationConfiguration) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/Generated/Runtime/Apis/DataApi.cs:249) Unity.Services.CloudSave.ApiClient.ForceSaveAsync (System.Collections.Generic.Dictionary
2[TKey,TValue] data) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/ApiClient.cs:57)
Unity.Services.CloudSave.SaveDataInternal.ForceSaveAsync (System.Collections.Generic.Dictionary2[TKey,TValue] data) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/SaveData.cs:158) Rethrow as CloudSaveException: HTTP/1.1 409 Conflict Unity.Services.CloudSave.SaveDataInternal.ForceSaveAsync (System.Collections.Generic.Dictionary
2[TKey,TValue] data) (at Library/PackageCache/com.unity.services.cloudsave@2.0.1/Runtime/SaveData.cs:171)
CloudSave.CloudSaveManager.UploadPlayerDataIntoCloud (System.String DataKey, System.Int32 DataValue) (at Assets/ACC_Multiplayer/Scripts/CloudSave/CloudSaveManager.cs:41)
System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <88d854ea2c91426ebc464f01cd71aa85>:0)
UnityEngine.UnitySynchronizationContext.Exec () (at <88d854ea2c91426ebc464f01cd71aa85>:0)
UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at <88d854ea2c91426ebc464f01cd71aa85>:0)