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

fix: NetworkManager ApprovalTimeout should not depend upon client synchronization #2261

Merged
merged 13 commits into from
Oct 18, 2022

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Oct 15, 2022

This bug was discovered in a Boss Room play test where the ClientConnectionBufferTimeout was set to 1 second. The underlying issue was that the ApprovalTimeout coroutine would depend upon the NetworkManager.IsConnectedClient to be determine if the client has been approved. This is problematic because NetworkManager.IsConnectedClient (when scene management is enabled) is set once the client has already been approved and has been fully synchronized. If the time it takes a client to synchronize exceeds the ClientConnectionBufferTimeout then while the client was approved it would time out anyway.

Here is how this fix addresses the issue:

  • It adds a new internally set property NetworkManager.IsApproved which is set upon the client being approved.
  • The timeout messages have been updated with more pertinent/useful information about the timeout.

MTT-4895

Changelog

  • Added: NetworkManager.IsApproved flag that is set to true a client has been approved.
  • Fixed: NetworkManager.ApprovalTimeout will not timeout due to slower client synchronization times as it now uses the added NetworkManager.IsApproved flag to determined if the client has been approved or not.

Testing and Documentation

  • Includes integration test update to ConnectionApprovalTimeoutTests.
  • Includes new API xml documentation for NetworkManager.IsApproved

This fix separates the IsConnectedClient from the approval process by adding an IsApproved flag.
This also has a possible fix for the domain backup error during serialization.
This is the final update for the ApprovalTimeout updates.
It accounts for latency and logs more meaningful information for the users.
The latency adjustments are capped at no more than 1 second longer than the specified ClientConnectionBufferTimeout to prevent from latency derived attacks.
Added the ability to bypass the entire NetcodeIntegrationTest connection approval process after the server and clients have been started.  This allows us to now use NetcodeIntegrationTest for unique connection oriented tests without being bound to the asserts if not all clients connected properly.
This is a bit of a refactoring for ConnectionApprovalTimeoutTests. It uses the added m_BypassConnectionTimeout to bypass the waiting for clients to connect. It still uses the message hook catch technique to simulate the timeout scenarios where either a server detects a transport connection but never receives a connection request or a client sends the connection request but never receives approval for the connection.
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner October 15, 2022 21:17
@NoelStephensUnity NoelStephensUnity marked this pull request as draft October 15, 2022 21:22
@@ -232,6 +232,10 @@ private void BuildDestinationToTransitionInfoTable()
private void BuildTransitionStateInfoList()
{
#if UNITY_EDITOR
if (UnityEditor.EditorApplication.isUpdating)
Copy link
Collaborator Author

@NoelStephensUnity NoelStephensUnity Oct 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might get removed and placed into a really small PR, but it seems to fix the "domain backup" errors we have been seeing during serialization with the more recent versions of Unity (a known issue).

NoelStephensUnity and others added 5 commits October 15, 2022 16:27
minor adjustment to the comments.
Fixing issue where a shutdown could be in progress and the transport driver was already disconnected/deallocated.
Adding the early exit if a shutdown is in progress
updating some of the names and comments.
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review October 17, 2022 19:23
Removing the RTT latency stuff.
was not resetting the m_BypassConnectionTimeout value... although this shouldn't have mattered that much since it is reset for each new NetcodeIntegrationTest instance.
@NoelStephensUnity NoelStephensUnity merged commit 73ac141 into develop Oct 18, 2022
@NoelStephensUnity NoelStephensUnity deleted the fix/separate-approval-from-clientconnected branch October 18, 2022 02:19
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…chronization (Unity-Technologies#2261)

* fix
This fix separates the IsConnectedClient from the approval process by adding an IsApproved flag.
This also has a fix to prevent the domain backup error during serialization.

* test
Added the ability to bypass the entire NetcodeIntegrationTest connection approval process after the server and clients have been started.  This allows us to now use NetcodeIntegrationTest for unique connection oriented tests without being bound to the asserts if not all clients connected properly.
Refactored for ConnectionApprovalTimeoutTests to use the added m_BypassConnectionTimeout to bypass the waiting for clients to connect. It still uses the message hook catch technique to simulate the timeout scenarios where either a server detects a transport connection but never receives a connection request or a client sends the connection request but never receives approval for the connection.
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

Successfully merging this pull request may close these issues.

2 participants