Sign In Register

How can we help you today?

Start a new topic

Timeouts

There are several threads on the topic - but I don't see a definitive answer along these lines.

Unity - C#...


In PlatformBase.cs, there is a field called RequestTimeoutSeconds.

In calling any  GSTypedRequest.Send, you can pass a timeoutSeconds


Is the PlatformBase value a default if no value is sent into Send?  Will the timeoutSeconds override the RequestTimeoutSeconds?


Also - Under what circumstances does GS.Available actually show false?  I would have thought that after several timeouts (via the above settings) and plenty of "GS: Connecting to:wss:......." statements that never succeed, I would thing that the GS.Available might change to false at some point.


thanks in advance!



Thanks Jeff,


The team is looking into this.


Oisin

Hey Jeff,

Thats right, the the time-out value on the platform is default, but it is possible to override the timeout by passing it directly into the send.

As for the GS.Available, it is a trick circumstance.
We dont automatically re-check a gamesparks connection once the connection is initially established. There is a check with OnApplicationPause which will disconnect and then reconnect GS.
So what this means is that GS.Available will be false if the SDK has not been setup just, but if the client gets disconnected from the game, then we have no way of sending back a message to the client to tell them it is not available, as the websocket is not open.

To alleviate any problems this can cause we have the durable requests option will will store the request locally until a connection is found.

Sean

 

Let me ask this another way.

What is the recommended way to determine (post connection/auth) if the client is still connected to the server instance?

For example - let's say I fire up a client (in-editor Unity example) - and connect/authenticate.

All is well - then I shut off my WIFI and attempt to send a LogEvent  - 

What appears to happen now - is that I eventually (after the PlatformBase.RequestTimeoutSeconds has elapsed) I get a response that looks like this - ' {"error":"timeout"}'.  That makes sense I guess - but I have no way to differentiate that from a LogEvent call that IS talking to the server but takes an abnormally long time to respond (slow cloud code - or inefficient mongo access - whatever).  

The gamesparks SDK seems to know there is a connectivity issue - as it immediately (upon timeout) attempts to (I think) re-establish the websocket (gleaned from seeing this in the logs "GS: Connecting to:wss://......").


What I am attempting to do is implement some retry logic.  The mobile device the player is using could have been going through a tunnel - or dropped wifi temporarily as they moved between locations - and I want to gracefully retry that LogEvent.  Keying off that 'timeout' error above is scary - as it might NOT be an indication that they have lost connectivity - but instead that the processing server-side was taking a long time - and it might eventually FINISH - so sending the same request again is less-than-desirable.  


So I guess what I am asking is that the Unity GS SDK seems to KNOW there is a communications problem - as it seems to be attempting to establish the websocket in the above case.  How can I tap into that knowledge ?


(I don't want to use durable requests - as I don't really want these events to send later when the UI has moved on to other things and the response data can't be properly processed/integrated into where the player is NOW in the application.


Thanks in advance !!


2 people like this

Same here,


Any updates on the latest comment?


1 person likes this

The behavior i seem to be seeing when calling  GSTypedRequest.Send(..., timeoutSeconds) is that the timeout used will be the maximum of the timeoutSeconds param passed in and the previously set RequestTimeoutSeconds system value. I was expecting to see the timeoutSeconds directly override RequestTimeoutSeconds value. Does it actually use the max of these two values in determining the timeout per request?

Hi All, 


I'll get a definitive answer to this question and reply here with an update. 

Best Regards, Patrick. 

I want to implement a retry system as well. Any news on this questions?


The problem is always going to be that the server cannot know that it has been disconnect because of the way our websockets communicate. So you do anyways have to let the SDK figure out the connection is dropped before the SDK knows there is a problem and resets the GS.Available bool. There is no way to work around this on the SDK because it cant tell the difference between a slow connection and a dead one.  One option  that is commonly used, but its a bit messy in my opinion is to ping google (for example) at regular intervals so see if there is an internet connection (depends on the platform you are using as to whether there is a reliable API that can tell for for definite the device has connectivity. Some APIs assume connectivity because you are connected to a router, even if that router is not connected to the internet).

There is a rough example attached which was used to solve the issue a customer had where they wanted to stop requests being sent until GameSparks resolved the connection.
This example however, does still need the SDK to figure out the connection has dropped from a timeout before GS.Available will be set to false again.

cs

Will a timeout always trigger GS to try to reconnect?

Login to post a comment