Skip to content

Commit bb9dbf1

Browse files
fix: connection approval cannot exceed mtu size - backport (3564) (#3565)
This PR resolves the issue where a NetworkConfig.ConnectionData that caused the ConnectionRequestMessage to exceed the transport's MTU size would result in a buffer overflow error by updating ConnectionRequestMessage to use the ReliableFragmentedSequenced pipeline as opposed to the ReliableSequenced pipeline. [MTTB-1467](https://jira.unity3d.com/browse/MTTB-1467) ## Changelog - Fixed: issue where NetworkConfig.ConnectionData could cause the ConnectionRequestMessage to exceed the transport's MTU size and would result in a buffer overflow error. ## Testing and Documentation - Includes modifications to `ConnectionApproval` integration tests to use a > MTU size `NetworkConfig.ConnectionData`. - No documentation changes or additions were necessary. ## Backport This is a back port of #3564.
1 parent 2939f8b commit bb9dbf1

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ Additional documentation and release notes are available at [Multiplayer Documen
1010

1111
### Added
1212

13+
### Fixed
14+
15+
- Fixed issue where NetworkConfig.ConnectionData could cause the ConnectionRequestMessage to exceed the transport's MTU size and would result in a buffer overflow error. (#3565)
16+
17+
### Changed
18+
19+
## [1.14.0] - 2025-07-21
20+
21+
### Added
22+
1323
- Added serializer for `Pose` (#3540)
1424
- Added mappings between `ClientId` and `TransportId`. (#3515)
1525
- Added `SinglePlayerTransport` that provides the ability to start as a host for a single player network session. (#3475)

com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ private void SendConnectionRequest()
626626
}
627627
}
628628

629-
SendMessage(ref message, NetworkDelivery.ReliableSequenced, NetworkManager.ServerClientId);
629+
SendMessage(ref message, NetworkDelivery.ReliableFragmentedSequenced, NetworkManager.ServerClientId);
630630
message.MessageVersions.Dispose();
631631
}
632632

com.unity.netcode.gameobjects/Tests/Runtime/ConnectionApproval.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public ConnectionApprovalTests(PlayerCreation playerCreation)
3434

3535
protected override int NumberOfClients => 1;
3636

37-
private Guid m_ValidationToken;
37+
private string m_ValidationToken;
3838

3939
protected override bool ShouldCheckForSpawnedPlayers()
4040
{
@@ -46,8 +46,13 @@ protected override void OnServerAndClientsCreated()
4646
m_ClientDisconnectReasonValidated = false;
4747
m_BypassConnectionTimeout = m_PlayerCreation == PlayerCreation.FailValidation;
4848
m_Validated.Clear();
49-
m_ValidationToken = Guid.NewGuid();
50-
var validationToken = Encoding.UTF8.GetBytes(m_ValidationToken.ToString());
49+
m_ValidationToken = string.Empty;
50+
51+
while (m_ValidationToken.Length < 2000)
52+
{
53+
m_ValidationToken += Guid.NewGuid().ToString();
54+
}
55+
var validationToken = Encoding.UTF8.GetBytes(m_ValidationToken);
5156
m_ServerNetworkManager.ConnectionApprovalCallback = NetworkManagerObject_ConnectionApprovalCallback;
5257
m_ServerNetworkManager.NetworkConfig.PlayerPrefab = m_PlayerCreation == PlayerCreation.Prefab ? m_PlayerPrefab : null;
5358
if (m_PlayerCreation == PlayerCreation.PrefabHash)

0 commit comments

Comments
 (0)