I’m using the nakama-template to make a docker deployment, and with the nakama-unity client demo, doesn’t change anything except the deployment host ip, always get an error ApiResponseException, the following is the detail:
Nothing modified, just the host.
- Versions: Nakama 3.9, Docker deployment, client library (Unity 2019.4)
try
{
const string scheme = "http";
string host = serverText;
int port = Int32.Parse(serverPortText);
const string serverKey = "defaultkey";
_client = new Client(scheme, host, port, serverKey, UnityWebRequestAdapter.Instance);
_socket = _client.NewSocket();
_socket.Closed += () => Debug.Log("Socket closed.");
_socket.Connected += () => Debug.Log("Socket connected.");
_socket.ReceivedError += e => Debug.Log("Socket error: " + e.Message);
// Cant use SystemInfo.deviceUniqueIdentifier with WebGL builds.
var udid = PlayerPrefs.GetString(UdidKey, Guid.NewGuid().ToString());
Debug.Log("Unique Device ID: " + udid);
ISession session;
var sessionToken = PlayerPrefs.GetString(SessionTokenKey);
Debug.Log("Try get session: " + SessionTokenKey);
if (string.IsNullOrEmpty(sessionToken) || (session = Session.Restore(sessionToken)).IsExpired)
{
session = await _client.AuthenticateDeviceAsync(udid);
PlayerPrefs.SetString(UdidKey, udid);
PlayerPrefs.SetString(SessionTokenKey, session.AuthToken);
}
Debug.Log("Session Token: " + session.AuthToken);
await _socket.ConnectAsync(session, true);
Debug.Log("Connected ");
var match = await _socket.CreateMatchAsync();
Debug.Log("Created match: " + match.Id);
await _socket.CloseAsync();
}
catch (Exception e)
{
Debug.LogError(e.ToString());
}