#How to handle when client connects before server starts listening?
9 messages · Page 1 of 1 (latest)
I just tried to listen to Transport.active.OnClientDisconnected and call NetworkManager.StartClient(uri); after one second. This results in client failing with this error upon reconnect:
This would never happen in the real world...server would always be running so clients can always connect
@old ruin in our prod setup this isn't the case. We often will startup servers on demand and client may start connecting before server finishes starting (kubernetes sometimes takes a bit to spin up a pod)
In this scenario i'm trying to use unity's new MPPM tooling to auto start a server in a separate window.
FWIW i'm migrating from fish-net to Mirror. Mirror has been great so far but this has tripped me up.
maybe you can add a reconnect event to the network transport.
KcpTransport's Awake()
client = new KcpClient(
() => OnClientConnected.Invoke(),
(message, channel) => OnClientDataReceived.Invoke(message, FromKcpChannel(channel)),
() =>
{
if (!NetworkClient.isConnected)
{
//TODO: Your timeout event
}
OnClientDisconnected?.Invoke();
}, // may be null in StopHost(): https://github.com/MirrorNetworking/Mirror/issues/3708
(error, reason) => OnClientError.Invoke(ToTransportError(error), reason),
config
);
Will try that, thank you!