if the server is active and have a session ID in Playfab - the game (mirror) doesn't connect to it
if the server is in Standby and have no session ID - the game connects successfully every time to the ip and port
what can I do ?
if the server is active and have a session ID in Playfab - the game (mirror) doesn't connect to it
if the server is in Standby and have no session ID - the game connects successfully every time to the ip and port
what can I do ?
May I ask how do you get the IP and port when a server is in standby and no session ID? Usually there are only 2 methods to get IP and port -- via RequestMultiplayerServer API or GetMatch API.
Do you mean after RequestMultiplayerServer is called, you can not connect the server instance using the IP and port from callback result?
Still, to help you solve this issue, may I know how do you get the IP and port when a server is in standby and no session ID? Is it from a previous call?
Found the Issue
In the Mirror version I am using v32.1.4 (maybe all future versions not sure)
you should not set the network manager to listen in AgentListener.cs in the official MpsSamples
here :
after this small change everything works great now
private void OnServerActive() { UnityNetworkServer.Instance.StartListen(); //<----------------Remove This line Debug.Log("Server Started From Agent Activation"); }
I guess that's why for me it was working when connecting to a standby server
This solved my problem as well. Thanks Abdulhai! I spent many hours on this bug.
I forgot to mention that I haven't figured out why this works yet. This should cause an error in the Mirror NetworkManager. TelepathyTransport should be listening on the wrong port. Without overriding it, it is listening on whatever port was set in the inspector before build.
The Mirror Server port is set by Agent listener as follow:
NetworkManagerCustom.Instance.Port = portInfo.Single().ServerListeningPort.
When we comment out StartListen.
[Server] private void OnServerActive() { //NetworkManagerCustom.Instance.StartListen(); Debug.Log("Server Started From Agent Activation"); }
The Server never sets the Mirror Telepathy Port to the one provided by AgentListener/PlayFab because the following code is the only place that the port is set by NetworkManager:
#if ENABLE_PLAYFABSERVER_API public void StartListen() { this.GetComponent<TelepathyTransport>().port = (ushort)Port; NetworkServer.Listen(maxConnections);
To be clear, an instance won’t switch back to standby state. The Lifecycle of a server instance ends when it is shutdown, while the resource will be released to the pool. The standby server you have seen is a newly created one by Docker.
You should not cache any IP and port because that information will be invalid when this instance is shutdown. You can still connect to the server build possibly because the server still in shutdown process or other states like onMaintenance and you don’t define any codes to destroy connections when entering shutdown process.
Each server instance is independent (so are the IP and port) and you cannot use an old IP and port to connect a new instance.
@SethDu please check the Image
3 People are following this question.