@@ -72,6 +72,41 @@ 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 ` is thread-safe and reuses a pooled ` HttpClient ` across
78+ requests. Idle connections in the pool can be silently closed by load
79+ balancers or other intermediaries. When the next request reuses one of these
80+ half-closed connections, the JDK reports the failure as a ` Connection reset `
81+ (or ` Broken pipe ` ) ` IOException ` .
82+
83+ To smooth over these intermittent transport failures, the SDK retries once by
84+ default. The retry covers:
85+
86+ * ` SocketException ` with message ` Connection reset ` or ` Broken pipe ` ,
87+ * ` ConnectException ` ,
88+ * ` HttpConnectTimeoutException ` .
89+
90+ Retries are ** not** applied to request-phase timeouts (` HttpTimeoutException ` )
91+ or to HTTP 4xx / 5xx responses. Web service requests are idempotent GETs, so
92+ retried requests are byte-identical to the original.
93+
94+ You can change the retry budget via the builder:
95+
96+ ``` java
97+ WebServiceClient client = new WebServiceClient .Builder (42 , " license_key" )
98+ .maxRetries(2 ) // up to two retries (three total attempts)
99+ .build();
100+ ```
101+
102+ Set ` .maxRetries(0) ` to disable the retry entirely. Negative values throw
103+ ` IllegalArgumentException ` .
104+
105+ If you frequently see ` Connection reset ` errors, you can also reduce the
106+ JDK's keep-alive timeout via the system property
107+ ` jdk.httpclient.keepalive.timeout ` (in seconds) to evict pooled connections
108+ before any intermediary does so.
109+
75110## Web Service Example ##
76111
77112### Country Service ###
0 commit comments