Cannot launch github demo client code

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.

  1. 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());
            }

Couple of questions;

  • What port number are you connecting to? 7350 or 7349?
  • How did you deploy your server, using our docker-compose file?

Thanks for reply! Here is my config:

  1. The nakama-unity client is connecting to 7350
  2. Using a standard docker-compose file from official.

All code I’m using is from offcial, running the WebGL code snippet, all I modified is the host IP, which I changed to my remote deploy host

The wired thing is, with localhost connection, it works, while switch to the remote, the error raised,
I can locate the error raised at session = await _client.AuthenticateDeviceAsync(udid);, but still confusing why…

Yes this looks like your Docker container isn’t exposed to outside of the local host machine. You need to check Docker network settings and your local machines firewall to allow incoming traffic.

Still thanks for reply! I get the point! It’s my local computer network problem, the LAN proxy somehow was selected. :exploding_head: