I have a function that downloads and shows data stored in a JSON file from Firebase. It downloads data from a company, so the user fills in a pincode and then it downloads the data from that company.
I tested this in Unity and it works like it should, it also works on webgl. However there is one company that is quite large and has a lot of data, again in Unity it works without any problems, it loads and shows the data. But on Webgl I get the error “Request Failed![0]” 2 times, 1 at around 60% and 1 at around 90%.
There are no “CORS” errors and I also tried increasing the timeout but with no results. I suspect it has something to do with the size of the data, but I am not sure.
I tested on multiple different browsers as well with no result.
here is the part of code that downloads the data:
public static void GetCompanyReport(UnityAction<ReportRequest> callback = null)
{
AuthHandler.GetIdToken(tokenCallback =>
{
if (tokenCallback.IsSuccess)
{
HTTPRequest request = new HTTPRequest(new System.Uri(FirebaseConfig.Instance.DatabaseURL + @"/Test/TestData"), HTTPMethods.Post, (req, response) =>
{
Debug.Log("Reached Code in GetCompanyReport Block 1");
if (response.IsSuccess)
{
Debug.Log("Reached Code in GetCompanyReport Block 2");
Debug.Log("Reached Code in GetCompanyReport Block 3");
ReportRequest resp = JsonUtility.FromJson<ReportRequest>(response.DataAsText);
Debug.Log("Request Finished! Text received: " + response.DataAsText);
resp.IsSuccess = true;
callback?.Invoke(resp);
}
else
{
bool keepGoing = NetworkErrorHandler.HandleError(response.StatusCode);
Debug.LogError("Request Failed![" + response.StatusCode + "]" + response.Message);
if (keepGoing)
{
ServerManager.NetworkResponse resp = ServerManager.NetworkResponse.Fail;
resp.errorcode = response.StatusCode;
Debug.LogError("Request Failed![" + response.StatusCode + "]" + response.Message);
callback?.Invoke(resp as ReportRequest);
}
}
});
Debug.Log("Reached code in GetCompanyReport Block 4");
request.Timeout = TimeSpan.FromSeconds(500);
Debug.Log("Reached code in GetCompanyReport Block 5");
request.AddHeader("Content-Type", "application/json");
var data = new BaseNetworkRequestData().SetPincode(CurrentCompany.publicdata.pincode).SetUserData().SetPincode();
string jsondata = JsonUtility.ToJson(data);
request.RawData = System.Text.Encoding.UTF8.GetBytes(jsondata);
Debug.Log(jsondata);
request.Send();
}
});
}