question

Konstantin Lapin avatar image
Konstantin Lapin asked

Strange time difference between client (unity) and PlayFab

Hello,
I encountered a strange time difference between my client (unity) and the backend (playfab). The client is about a second in the future or the backend is one second in the past. I am taking the utc time just before I call ExecuteCloudScript. Backend also logs the utc back to the client (log.debug). I expect the client behind the backend in UTC Time, but the client is a second in the future.


Example:
Unity 2019-09-06T07:26:52.8493162Z
Backend 2019-09-06T07:26:51.991Z



Is this a know behaviour, because the backend is somewhere else?
Is it related to the interpretation time of Javascript?



I am testing from the Unity Editor, Network delay should be low.


Thank you for your help

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image
Citrus Yan answered

Hi Konstantin,

You are saying that the time you get from the client is ahead of the time returned after calling ExecuteCloudScript. General speaking, backend time should be after client time in your case since it takes time to make a API request to the server and waiting for execution. I think the first thing you need to do is to make sure that the client time is synced. Also it would be helpful to provide the code snippet of your test for us to reproduce, thanks.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Konstantin Lapin avatar image
Konstantin Lapin answered

Hi Citrus Yan,

thank you for your answer, surprisingly this behaviour went away, but today it is back. I made a screenshot.

The Client time is the time right before I call PlayFabClientAPI.ExecuteCloudScript. The next entry is the backend time on playfab. I use "new Date(new Date().toISOString());" to get the UTC Time.

I am also expecting backend to be after the client time, I don't know why this happens. If you have any ideas please write. I will try to find the main reason for this.

Important to know, this only happens on mobile device and not computer.


times.png (14.0 KiB)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Citrus Yan avatar image Citrus Yan commented ·

Hi @Konstantin Lapin,

You are saying that this only happens on mobile devices but not computers, so it looks like the time on PlayFab backend is accurate. You may need to troubleshoot from the client-side to make sure its clock is accurate.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.