Timeouts?
-
Hello!
I work on a game made with Unity, and I have a general question about server requests and lost connections. If I make a call such as:_bc.EntityService.GetEntitiesByType(entityType, (string response, object cbObject) => { Debug.Log("SUCCESS"); }, (int statusCode, int reasonCode, string statusMessage, object cbObject) => { Debug.Log("FAIL"); });
What happens if the user lost connection before getting a response back? Do I get the fail callback? If so, after how long?
-
If the app makes a call to brainCloud that timeouts, it will generate a CLIENT_NETWORK_ERROR_TIMEOUT (90001) error in the failure callback.
_bc.EntityService.GetEntitiesByType(entityType, (string response, object cbObject) => { Debug.Log("SUCCESS"); }, (int statusCode, int reasonCode, string statusMessage, object cbObject) => { switch (reasonCode) { case ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT: { // Handle the timeout break; } } });
The brainCloud SDK will timeout after a set interval. Currently, in the 4.2 release, the default is 35 seconds, but this may be adjusted later.
You can also call SetPacketTimeouts to set a custom amount for your timeout values. But the defaults are recommended.
An example of handling a timeout error in Unity can be found in our AuthenticationErrorHandling example.
-
Hi,
A bit of a clarification.
Internally, the brainCloud client is automatically retrying for you.
The timeout setting is an array - the defaults are [15, 10, 10]. This means the first timeout is 15 seconds, then 10 seconds later, and 10 seconds after that. Totally 35 seconds.
If after those 3 retries the app was unable to get a valid response, it finally sends a retry to the client.
So, a couple of things:
- 1 - don't change the defaults to make them smaller. That just hits our server harder.
- 2 - Don't blindly retry calling brainCloud if the request times out. That's already been done 3 times! Could be their having mobile networking issues. Instead - pop up a retry dialog to your client.
PS - We are considering extending this timeout a bit - because its possible to have scripts that only timeout after 60 seconds - and they aren't automatically handled without adjusting the client timeouts.
The new values we are considering are 15, 20, 35, 50 - so the full timeout becomes 2 minutes, with excalating retries.
Hope that helps!
Paul.
-
Thanks guys! I figured it would be ridiculous if I had to do timeout checks and retries myself