diff --git a/src/Packages/UnityWebBrowser/Runtime/Communication/TCPCommunicationLayer.cs b/src/Packages/UnityWebBrowser/Runtime/Communication/TCPCommunicationLayer.cs
index a36eb695..2e234589 100644
--- a/src/Packages/UnityWebBrowser/Runtime/Communication/TCPCommunicationLayer.cs
+++ b/src/Packages/UnityWebBrowser/Runtime/Communication/TCPCommunicationLayer.cs
@@ -28,10 +28,23 @@ public sealed class TCPCommunicationLayer : CommunicationLayer
[Range(1024, 65353)] [Tooltip("The out port to communicate on")]
public int outPort = 5556;
+ ///
+ /// How long the client keeps trying to reach the engine before giving up, in milliseconds
+ ///
+ ///
+ /// This was previously hardcoded to , i.e. roughly 24 days of
+ /// retrying. If the engine process is already gone the connect loop therefore never
+ /// terminates, and because a Unity domain reload has to tear the client down, the reload
+ /// blocks on it - the editor hangs on "Reloading Domain (busy for ...)" indefinitely
+ /// rather than reporting a failed connection.
+ ///
+ [Range(1000, 600000)] [Tooltip("Give up connecting to the engine after this long (ms)")]
+ public int connectionTimeout = 30000;
+
public override Client CreateClient()
{
IPEndPoint ipEndPoint = new(IPAddress.Loopback, inPort);
- return new TCPClient(ipEndPoint, int.MaxValue);
+ return new TCPClient(ipEndPoint, connectionTimeout);
}
public override Host CreateHost()