Skip to content

feat: Improve error message on connection failure - #4207

Open
simon-lemay-unity wants to merge 4 commits into
develop-3.x.xfrom
fix/improve-failed-connect-error
Open

simon-lemay-unity wants to merge 4 commits into
develop-3.x.xfrom
fix/improve-failed-connect-error

Conversation

@simon-lemay-unity

@simon-lemay-unity simon-lemay-unity commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of this PR

Clients would previously just log "failed to connect to server" on a connection failure. While perfectly accurate, it's not particularly useful. This PR adds possible reasons for the connection failure, based on the transport configuration. The list of reasons is what I've observed most often on our forums, Discord, and customer tickets.

Jira ticket

UUM-155178

Changelog

Didn't think it was worth updating.

Documentation

  • No documentation changes or additions were necessary.

Testing & QA

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

Up-port

N/A

Backports

#4208

@simon-lemay-unity
simon-lemay-unity requested a review from a team as a code owner October 22, 2026 15:37

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Harness Review

LGTM

The expanded logging preserves the existing failure trigger, but its troubleshooting advice does not always match the transport actually created.

Reviewed commit 35946d5

🤖 Helpful? 👍/👎

{
reasons.Add($"Server/host might not be reachable. Try \"ping {ConnectionData.Address}\" in a terminal.");
reasons.Add("The firewall on the server/host might be blocking the connection attempts.");
if (m_UseEncryption && !m_UseWebSockets)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2

Encrypted WebGL clients with UseWebSockets=false receive advice to switch to WebSockets even though WebSockets are already active. In WebGL player builds, CreateDriver selects WebSocketNetworkInterface even when m_UseWebSockets is false. LogClientConnectionFailureMessage instead checks the serialized flag, so it incorrectly suggests that DTLS is involved. Determine whether WebSockets are effectively enabled, including the WebGL fallback. Use that result in both WebSocket checks in LogClientConnectionFailureMessage.

🤖 Helpful? 👍/👎

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You get a warning in the console when we end up using WebSockets even if UseWebSockets is false. It's not something that's supposed to happen on a correctly configured transport so I don't think it's worth handling here.

@codecov-github-com

codecov-github-com Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 53.57143% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...meobjects/Runtime/Transports/UTP/UnityTransport.cs 53.57% 13 Missing ⚠️
@@                Coverage Diff                @@
##           develop-3.x.x    #4207      +/-   ##
=================================================
- Coverage          76.03%   76.01%   -0.03%     
=================================================
  Files                159      159              
  Lines              27344    27371      +27     
=================================================
+ Hits               20791    20805      +14     
- Misses              6553     6566      +13     
Flag Coverage Δ
NGOv2_project_testproject_ubuntu 75.05% <53.57%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...meobjects/Runtime/Transports/UTP/UnityTransport.cs 76.12% <53.57%> (-0.81%) ⬇️
Components Coverage Δ
com.unity.netcode.gameobjects 76.01% <53.57%> (-0.03%) ⬇️

ℹ️ Need help interpreting these results?

@simon-lemay-unity
simon-lemay-unity enabled auto-merge (squash) October 23, 2026 04:32

This branch has not been deployed

No deployments
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.

4 participants