@@ -72,6 +72,46 @@ are not created for each request.
7272See the [ API documentation] ( https://maxmind.github.io/GeoIP2-java/ ) for
7373more details.
7474
75+ ### Connection pooling and transport retries ###
76+
77+ ` WebServiceClient ` reuses pooled HTTP connections for performance. Idle
78+ connections can be silently closed by load balancers or other
79+ intermediaries; when the next request reuses such a half-closed connection,
80+ the JDK reports the failure as a ` Connection reset ` , ` Broken pipe ` , or
81+ similar transport error.
82+
83+ To smooth over these intermittent failures, the SDK retries once by
84+ default. Most transport-level ` IOException ` s are retried; the SDK does
85+ ** not** retry:
86+
87+ * ** Timeouts** (` HttpTimeoutException ` , including connect-phase timeouts).
88+ The SDK honors the timeouts you configure rather than extending them.
89+ * ** Cancellation** (` InterruptedIOException ` , or any interrupt observed
90+ before the request runs).
91+ * ** Typically deterministic failures** — ` UnknownHostException ` ,
92+ ` ConnectException ` , ` SSLHandshakeException ` , ` SSLPeerUnverifiedException ` .
93+ Retrying these would just delay surfacing a config bug.
94+
95+ HTTP 4xx and 5xx responses are surfaced through the existing exception
96+ hierarchy and are never retried. Request bodies are replayable, so retried
97+ requests are byte-identical to the original.
98+
99+ You can change the retry budget via the builder:
100+
101+ ``` java
102+ WebServiceClient client = new WebServiceClient .Builder (42 , " license_key" )
103+ .maxRetries(2 ) // up to two retries (three total attempts)
104+ .build();
105+ ```
106+
107+ Set ` .maxRetries(0) ` to disable the retry entirely. Negative values throw
108+ ` IllegalArgumentException ` .
109+
110+ If you frequently see ` Connection reset ` errors, you can also reduce the
111+ JDK's keep-alive timeout via the system property
112+ ` jdk.httpclient.keepalive.timeout ` (in seconds) to evict pooled connections
113+ before any intermediary does so.
114+
75115## Web Service Example ##
76116
77117### Country Service ###
0 commit comments