heroiclabs / nakama-unity

Unity client for Nakama server.
https://heroiclabs.com/docs/unity-client-guide
Other
411 stars 75 forks source link

There is no callback for requesting data when the network is disconnected on SDK V3.1.1 #123

Closed xiaoleMu closed 2 years ago

xiaoleMu commented 2 years ago

We upgraded Nakama (the Game SDK) from "version": "2.9.3" to "version": "3.1.1". The initializing Nakama client interface is changed:

Cause a problem:

When the data is requested in the network disconnected state, the failure of the request will not be fed back immediately, the timeout does not take effect either, and there is no response call back after timeout.

In the previous version : "2.9.3". There is no such problem.

Steps to reproduce -

  1. Open the game
  2. Turn off mobile network and WiFi after AuthenticateDeviceAsync
  3. use to request storage data Unity 2019.2.17f1

the first request, we can get an error after time out: A task was canceled. the second request, there will be no response fed back.

Can you please check,thanks.

xiaoleMu commented 2 years ago

Here is our code. You can create a scene in unity and place this code on the object of the scene, and reproduce this issue according to the above reproduction steps.

using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Net.Sockets; using Nakama; using UnityEngine; using UnityEngine.UI;

public class MainManager : MonoBehaviour { private Client m_Client; private ISession m_SessionInfo; [SerializeField] private Button m_Button;

void LogError(string info)
{
    Debug.LogError($"[MainManager] {info}");
}

async void Start()
{
    m_Button.onClick.AddListener(() =>
    {
        RequestInfo();
    });
    m_Button.gameObject.SetActive(false);
    LogError("start Init");
    m_Client = new Client ("http", "54.180.17.191", 7350, "defaultkey", HttpRequestAdapter.WithGzip(), false);
    m_SessionInfo = await m_Client.AuthenticateDeviceAsync(SystemInfo.deviceUniqueIdentifier);
    LogError("end Init");
    m_Button.gameObject.SetActive(true);
}

async void RequestInfo()
{
    try {
        LogError("start request");
        var objectList = await m_Client.ListUsersStorageObjectsAsync (m_SessionInfo, "fashioncontest_outfit_data", "9e00d560-5cdf-4fcf-9a9c-1a9866813d9a", 1, null);
        LogError("end request");
        LogError($"objectList length = {objectList.Objects.Count()}");
    } catch (ApiResponseException e) {
        LogError(e.Message);
    } catch (SocketException e) {
        LogError(e.Message);
    } catch (Exception e) {
        LogError(e.Message);
    }
}

}

novabyte commented 2 years ago

A new release of the Unity client is available: https://github.com/heroiclabs/nakama-unity/releases/v3.3.0 Please test it and reopen this issue if the problem persists.