Skip to content

Bound the TCP client's connect timeout instead of int.MaxValue - #440

Open
MonoFinity wants to merge 1 commit into
Voltstro-Studios:masterfrom
MonoFinity:fix/bounded-engine-connect-timeout
Open

Bound the TCP client's connect timeout instead of int.MaxValue#440
MonoFinity wants to merge 1 commit into
Voltstro-Studios:masterfrom
MonoFinity:fix/bounded-engine-connect-timeout

Conversation

@MonoFinity

Copy link
Copy Markdown

The problem

TCPCommunicationLayer.CreateClient() passes int.MaxValue as VoltRpc's connectionTimeout:

return new TCPClient(ipEndPoint, int.MaxValue);

That is roughly 24 days of retrying. Against an engine process that is already gone the connect loop never terminates — and because a Unity domain reload has to tear the client down, the reload blocks on it. The symptom is the Editor sitting on Reloading Domain (busy for HH:MM) indefinitely rather than reporting a failed connection.

This is easy to hit in the Editor: any time the engine dies or is reaped (a crash, a stale process from a previous Play session, a port collision), the next domain reload wedges instead of surfacing the real failure. Recovering means killing the Editor.

The change

Make it a serialized field with a 30 s default:

[Range(1000, 600000)] [Tooltip("Give up connecting to the engine after this long (ms)")]
public int connectionTimeout = 30000;

So a dead engine surfaces as a connection failure, and a domain reload can always complete. The range leaves room for anyone who needs a longer wait on a slow cold start.

Why CreateHost() is left alone

CreateHost() also passes int.MaxValue, twice — but it's the listening side rather than a retry loop, and we've never observed it blocking a reload, so I didn't want to change it speculatively. Happy to bound it here too for symmetry if you'd prefer; just say which value.

Notes

TCPCommunicationLayer.CreateClient() passed int.MaxValue as VoltRpc's
connectionTimeout, i.e. roughly 24 days of retrying. Against an engine
process that 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 HH:MM)"
indefinitely instead of reporting a failed connection.

Make it a serialized field defaulting to 30000 ms, so a dead engine surfaces
as a connection failure and a domain reload can always complete. The range
is 1000-600000 ms for anyone who needs a longer wait on a slow cold start.

CreateHost() is left alone: it is the listening side rather than a retry
loop, and has not been observed blocking a reload.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant