I'm developing my networking game flow based off these two projects using Unity and Mirror. Title C8E30 (currently testing on the server: Word Client/Server Test UDP 4
https://github.com/natepac/playfabmirrorgameexample/tree/master
https://github.com/PlayFab/MpsSamples/tree/master/UnityMirror
I'm using a game configuration object in this version. If there is no IP in the configuration, I call PlayFabMultiplayerAPI.RequestMultiplayerServer and add the IP and Port to the network manager, then connect. I get the correct information, but seem to be immediately disconnected (client times out). When I use the same information directly in the configuration and skip the call to RequestMultiplayerServer, I connect and have no issues.
Same issues with matchmaking. I get the match and try for the server and get disconnected.
The calls to obtain the server info seem to be doing something server-side, but I'm not sure what. I put a 1 minute server shutdown timer on which seems to work fine (when connecting directly). I removed the empty server check when a player is removed (for testing purposes). Here are the code sections where I'm calling from the client.
//currently called from UI button public void ConnectToGameServer() { if (_mGameConfiguration.IpAddress == "") RequestMultiplayerServer(); else ConnectRemoteClient(); } private void RequestMultiplayerServer() { Debug.Log("[ClientStartUp].RequestMultiplayerServer"); //We need to grab an IP and Port from a server based on the buildId. //Copy this and add it to your Configuration. RequestMultiplayerServerRequest requestData = new RequestMultiplayerServerRequest { BuildId = _mGameConfiguration.BuildId, SessionId = System.Guid.NewGuid().ToString(), PreferredRegions = new List<string>() { Enum.GetName(typeof(AzureRegion), AzureRegion.EastUs) } }; PlayFabMultiplayerAPI.RequestMultiplayerServer(requestData, OnRequestMultiplayerSuccess, OnPlayFabCallbackError); } private void OnRequestMultiplayerSuccess(RequestMultiplayerServerResponse response) { //TODO debugging code string message = ""; foreach (ConnectedPlayer player in response.ConnectedPlayers) { message += $"Player: {player.PlayerId}\n"; } message += $"IP: {response.IPV4Address}\n"; message += $"Port: {response.Ports[0].Name} Protocol: {response.Ports[0].Protocol}\n"; message += $"ServerID: {response.ServerId}\n"; message += $"GameState: {response.State}\n"; OnUiMessage?.Invoke("Have Server", message); Debug.Log($"[ClientStartUp].OnRequestMultiplayerSuccess:\n {message}"); ConnectRemoteClient(response); } private void ConnectRemoteClient(RequestMultiplayerServerResponse response = null) { if (response == null) { _mUNetManager.networkAddress = _mGameConfiguration.IpAddress; _mTransport.Port = _mGameConfiguration.Port; } else { _mUNetManager.networkAddress = response.IPV4Address; _mTransport.Port = (ushort)response.Ports[0].Num; //TODO BUG find out why we disconnect in a short time on this one, possibly stop shutdown timer on server when player connected } _mUNetManager.StartClient(); },
I'm developing my networking game flow based off these two projects using Unity and Mirror. Title C8E30 (currently testing on the server: Word Client/Server Test UDP 4
https://github.com/natepac/playfabmirrorgameexample/tree/master
https://github.com/PlayFab/MpsSamples/tree/master/UnityMirror
I'm using a game configuration object in this version. If there is no IP in the configuration, I call PlayFabMultiplayerAPI.RequestMultiplayerServer and add the IP and Port to the network manager, then connect. I get the correct information, but seem to be immediately disconnected (client times out). When I use the same information directly in the configuration and skip the call to RequestMultiplayerServer, I connect and have no issues.
Same issues with matchmaking. I get the match and try for the server and get disconnected.
The calls to obtain the server info seem to be doing something server-side, but I'm not sure what. I put a 1 minute server shutdown timer on which seems to work fine (when connecting directly). I removed the empty server check when a player is removed (for testing purposes). Here are the code sections where I'm calling from the client.
//currently called from UI button public void ConnectToGameServer() { if (_mGameConfiguration.IpAddress == "") RequestMultiplayerServer(); else ConnectRemoteClient(); } private void RequestMultiplayerServer() { Debug.Log("[ClientStartUp].RequestMultiplayerServer"); //We need to grab an IP and Port from a server based on the buildId. //Copy this and add it to your Configuration. RequestMultiplayerServerRequest requestData = new RequestMultiplayerServerRequest { BuildId = _mGameConfiguration.BuildId, SessionId = System.Guid.NewGuid().ToString(), PreferredRegions = new List<string>() { Enum.GetName(typeof(AzureRegion), AzureRegion.EastUs) } }; PlayFabMultiplayerAPI.RequestMultiplayerServer(requestData, OnRequestMultiplayerSuccess, OnPlayFabCallbackError); } private void OnRequestMultiplayerSuccess(RequestMultiplayerServerResponse response) { //TODO debugging code string message = ""; foreach (ConnectedPlayer player in response.ConnectedPlayers) { message += $"Player: {player.PlayerId}\n"; } message += $"IP: {response.IPV4Address}\n"; message += $"Port: {response.Ports[0].Name} Protocol: {response.Ports[0].Protocol}\n"; message += $"ServerID: {response.ServerId}\n"; message += $"GameState: {response.State}\n"; OnUiMessage?.Invoke("Have Server", message); Debug.Log($"[ClientStartUp].OnRequestMultiplayerSuccess:\n {message}"); ConnectRemoteClient(response); } private void ConnectRemoteClient(RequestMultiplayerServerResponse response = null) { if (response == null) { _mUNetManager.networkAddress = _mGameConfiguration.IpAddress; _mTransport.Port = _mGameConfiguration.Port; } else { _mUNetManager.networkAddress = response.IPV4Address; _mTransport.Port = (ushort)response.Ports[0].Num; //TODO BUG find out why we disconnect in a short time on this one, possibly stop shutdown timer on server when player connected } _mUNetManager.StartClient(); }