Mirror icon indicating copy to clipboard operation
Mirror copied to clipboard

detect only mirror server problems (not user network or.. problems)

Open hdev72 opened this issue 2 years ago • 3 comments

I am using Mirror Networking and the SimpleWeb transport in Unity. I want to be able to detect when there is an issue on the server side, preventing users from connecting to the Mirror server. For instance, if the server becomes unavailable or terminates connections due to its own problems, I need to be notified of these events. My goal is to identify server-side issues rather than user-side problems.

hdev72 avatar Aug 19 '23 09:08 hdev72

I'm experiencing a similar problem (but with Telepathy transport). If I attempt to connect and the server is unavailable - detecting this is difficult. Or also if during a session, the network drops - I'd like specific events related to the actual connection. Hooking this to client status events is very messy.

wilks-ftf avatar Sep 20 '23 21:09 wilks-ftf

One thing I can think of is for Mirror to emit a DisconnectReason - which I don't think exists already but I could be wrong since it's been ages since I last properly sat down and looked at Mirror.

Mirage does have such a enum that has predefined reasons why a connection was terminated upon disconnection. Speaking from that standpoint, if the server terminates your connection due to a exception, you get ClosedByRemote or if something was corrupt, you get a Corruption response. Having a disconnect reason would allow you to display a friendly message, for example for a Corruption event one popup could be "Check your internet connection. Packet data integrity has been compromised and gameplay has been terminated".

However, this would not help you if the server suddenly chokes and dies a horrible SIGSEGV (segmentation fault) death or say, the Linux kernel sends a SIGKILL signal to kill the game process because it had a memory leak. To Mirror, it would just be seen as a timeout condition. To the best of my knowledge, there is no way to have the grim reaper wait for a few seconds before the Unity runtime instance is terminated (in the context that you want to send out the "Server going down now" messages).

It may be possible to do something like Source's networking where you get a "WARNING: Connection problem. Disconnecting in 30.0s" when the network seems to have stalled, but I don't know how much work (and by that the priority of the idea) that'll be for Mirror's dev team.

SoftwareGuy avatar Sep 21 '23 01:09 SoftwareGuy

One thing I can think of is for Mirror to emit a DisconnectReason - which I don't think exists already but I could be wrong since it's been ages since I last properly sat down and looked at Mirror.

Mirage does have such a enum that has predefined reasons why a connection was terminated upon disconnection. Speaking from that standpoint, if the server terminates your connection due to a exception, you get ClosedByRemote or if something was corrupt, you get a Corruption response. Having a disconnect reason would allow you to display a friendly message, for example for a Corruption event one popup could be "Check your internet connection. Packet data integrity has been compromised and gameplay has been terminated".

However, this would not help you if the server suddenly chokes and dies a horrible SIGSEGV (segmentation fault) death or say, the Linux kernel sends a SIGKILL signal to kill the game process because it had a memory leak. To Mirror, it would just be seen as a timeout condition. To the best of my knowledge, there is no way to have the grim reaper wait for a few seconds before the Unity runtime instance is terminated (in the context that you want to send out the "Server going down now" messages).

It may be possible to do something like Source's networking where you get a "WARNING: Connection problem. Disconnecting in 30.0s" when the network seems to have stalled, but I don't know how much work (and by that the priority of the idea) that'll be for Mirror's dev team.

Any disconnect reason can only be sent unreliable, so its just a best try effort, you should never rely on it. The only way to detect server issues is to have a master server your server report to, but thats not really something mirror related.

FakeByte avatar Jan 28 '24 05:01 FakeByte