Skip to content

fix: Prevent an exception in UTP when host disconnects #1441

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

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

simon-lemay-unity
Copy link
Contributor

The code was invoking the disconnect transport event callback on the manager before doing some checks on UTP's NetworkConnection. But on a client, that callback ends up calling Shutdown on the transport. This disposes of the driver so the checks that follow end up throwing an exception. The fix was to reorder the checks before the callback.

Also fix the logic that checked if there was a connection failure. It was checking if the state of the connection was Connecting, but that's never the case after a Disconnect event (the state will always be Disconnected). Instead, check the disconnect reason.

Fixes #1439.

Changelog

com.unity.netcode.adapter.utp

  • Fixed: Don't throw an exception when the host disconnects.

Testing and Documentation

  • No tests have been added.
  • No documentation changes or additions were necessary.

The code was invoking the disconnect transport event callback on the
manager before doing some checks on UTP's NetworkConnection. But on a
client, that callback ends up calling Shutdown on the transport. This
disposes of the driver so the checks that follow end up throwing an
exception. The fix was to reorder the checks before the callback.

Also fix the logic that checked if there was a connection failure. It
was checking if the state of the connection was Connecting, but that's
never the case after a Disconnect event (the state will always be
Disconnected).
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.

Error on unexpected host disconnect using Unity Transport UnityTransport random ObjectDisposedException on disconnect
2 participants