Class NetworkConfig
-
- All Implemented Interfaces:
public final class NetworkConfigSettings-group for the timeouts applied to every outbound HTTP call ServerPackCreator makes.
These exist because the JDK's default is to wait forever: an
HttpURLConnectionwith no timeouts set never gives up on a host which accepts the connection and then goes silent, which is exactly what a black-holing firewall or a stalled upstream looks like. Twelve manifest checks sit on the blocking startup path, so an unbounded wait there is a hang with no recovery rather than a slow start.Two timeouts are separate on purpose, because they answer different questions:
connect bounds reaching the host at all, and can be short — either the TCP handshake completes quickly or the host is not there.
read bounds how long a single read may block waiting for bytes. It is not a budget for the whole transfer, which is why a multi-megabyte download does not need a huge value — only a host that stalls mid-stream for longer than the timeout trips it.
downloadReadTimeout is nevertheless separate from readTimeout because the two are used against different things: a metadata manifest either answers promptly or is broken, while an installer or mod jar is legitimately served by hosts that trickle bytes under load.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringCONNECT_TIMEOUT_KEYpublic final static StringREAD_TIMEOUT_KEYpublic final static StringDOWNLOAD_READ_TIMEOUT_KEYpublic final static IntegerDEFAULT_CONNECT_TIMEOUTpublic final static IntegerDEFAULT_READ_TIMEOUTpublic final static IntegerDEFAULT_DOWNLOAD_READ_TIMEOUTprivate final IntegerfallbackConnectTimeoutprivate final IntegerfallbackReadTimeoutprivate final IntegerfallbackDownloadReadTimeoutprivate IntegerconnectTimeoutprivate IntegerreadTimeoutprivate IntegerdownloadReadTimeout
-
Constructor Summary
Constructors Constructor Description NetworkConfig(PropertyStore store)
-
Method Summary
Modifier and Type Method Description final IntegergetFallbackConnectTimeout()Fallback milliseconds to wait for a connection to be established. final IntegergetFallbackReadTimeout()Fallback milliseconds a single read of a metadata response may block. final IntegergetFallbackDownloadReadTimeout()Fallback milliseconds a single read of a file-download may block. final IntegergetConnectTimeout()Milliseconds to wait for a connection to be established before giving up. final UnitsetConnectTimeout(Integer value)Milliseconds to wait for a connection to be established before giving up. final IntegergetReadTimeout()Milliseconds a single read of a metadata response (version manifests, reachability checks) may block before the call gives up. final UnitsetReadTimeout(Integer value)Milliseconds a single read of a metadata response (version manifests, reachability checks) may block before the call gives up. final IntegergetDownloadReadTimeout()Milliseconds a single read of a file-download (installers, mod jars) may block before the download is abandoned. final UnitsetDownloadReadTimeout(Integer value)Milliseconds a single read of a file-download (installers, mod jars) may block before the download is abandoned. -
-
Constructor Detail
-
NetworkConfig
NetworkConfig(PropertyStore store)
-
-
Method Detail
-
getFallbackConnectTimeout
final Integer getFallbackConnectTimeout()
Fallback milliseconds to wait for a connection to be established. Short by design: a reachable host completes the handshake in well under this, so a longer value only prolongs the wait on hosts which are not there.
-
getFallbackReadTimeout
final Integer getFallbackReadTimeout()
Fallback milliseconds a single read of a metadata response may block.
-
getFallbackDownloadReadTimeout
final Integer getFallbackDownloadReadTimeout()
Fallback milliseconds a single read of a file-download may block. Larger than fallbackReadTimeout because installers and mod jars are served by hosts which trickle bytes under load, where a stalled metadata endpoint is simply broken.
-
getConnectTimeout
final Integer getConnectTimeout()
Milliseconds to wait for a connection to be established before giving up.
See sanitise for how invalid values are handled, and note that
0is a deliberate escape hatch meaning "wait forever" — the JDK's own semantics, and the behaviour SPC had before these settings existed.
-
setConnectTimeout
final Unit setConnectTimeout(Integer value)
Milliseconds to wait for a connection to be established before giving up.
See sanitise for how invalid values are handled, and note that
0is a deliberate escape hatch meaning "wait forever" — the JDK's own semantics, and the behaviour SPC had before these settings existed.
-
getReadTimeout
final Integer getReadTimeout()
Milliseconds a single read of a metadata response (version manifests, reachability checks) may block before the call gives up.
-
setReadTimeout
final Unit setReadTimeout(Integer value)
Milliseconds a single read of a metadata response (version manifests, reachability checks) may block before the call gives up.
-
getDownloadReadTimeout
final Integer getDownloadReadTimeout()
Milliseconds a single read of a file-download (installers, mod jars) may block before the download is abandoned.
-
setDownloadReadTimeout
final Unit setDownloadReadTimeout(Integer value)
Milliseconds a single read of a file-download (installers, mod jars) may block before the download is abandoned.
-
-
-
-