Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hdev72 opened this issue Aug 19, 2023 · 3 comments
Open

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

hdev72 opened this issue Aug 19, 2023 · 3 comments

Comments

@hdev72
Copy link

hdev72 commented Aug 19, 2023

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.

@wilks-ftf
Copy link

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.

@SoftwareGuy
Copy link
Contributor

SoftwareGuy commented Sep 21, 2023

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.

@FakeByte
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants