Skip to content

Commit be34997

Browse files
authored
fix: Block websocket use in dedicated server builds (#3336)
<!-- Replace this block with what this PR does and why. Describe what you'd like reviewers to know, how you applied the engineering principles, and any interesting tradeoffs made. Delete bullet points below that don't apply, and update the changelog section as appropriate. --> Ensure users are not using websockets when building dedicated game server builds <!-- Add short version of the JIRA ticket to the PR title (e.g. "feat: new shiny feature [MTT-123]") --> [MTT-11522](https://jira.unity3d.com/browse/MTT-11522) [MTTB-613](https://jira.unity3d.com/browse/MTTB-613) <!-- Add RFC link here if applicable. --> ## Changelog - Fixed: Blocks trying to create a dedicated server build with a websocket connection on Unity Transport. ## Testing and Documentation - No tests have been added.
1 parent 0e475bc commit be34997

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
3131

3232
### Changed
3333

34+
- Ensured that a useful error is thrown when attempting to build a dedicated server with Unity Transport that uses websockets. (#3336)
3435
- Changed root in-scene placed `NetworkObject` instances now will always have either the `Distributable` permission set unless the `SessionOwner` permission is set. (#3305)
3536
- Changed the `DestroyObject` message to reduce the serialized message size and remove the unnecessary message field. (#3304)
3637
- Changed the `NetworkTimeSystem.Sync` method to use half RTT to calculate the desired local time offset as opposed to the full RTT. (#3212)

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,21 @@ public void CreateDriver(UnityTransport transport, out NetworkDriver driver,
16681668
}
16691669
#endif
16701670

1671+
#if UNITY_SERVER
1672+
if (m_ProtocolType == ProtocolType.RelayUnityTransport)
1673+
{
1674+
if (m_UseWebSockets)
1675+
{
1676+
Debug.LogError("Transport is configured to use Websockets, but websockets are not available on server builds. Ensure that the \"Use WebSockets\" checkbox is checked under \"Unity Transport\" component.");
1677+
}
1678+
1679+
if (m_RelayServerData.IsWebSocket != 0)
1680+
{
1681+
Debug.LogError("Relay server data indicates usage of WebSockets, but websockets are not available on server builds. Be sure to use \"dtls\" or \"udp\" as the connection type when creating the server data");
1682+
}
1683+
}
1684+
#endif
1685+
16711686
#if UTP_TRANSPORT_2_0_ABOVE
16721687
if (m_UseEncryption)
16731688
{

0 commit comments

Comments
 (0)