You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e4ea451
Browse filesBrowse the repository at this point in the historyBrowse files
feat: add opt-in retry for rate-limited and transport-failed requests (#75)
* feat: add opt-in retry for rate-limited and transport-failed requests
GET/HEAD requests failing with HTTP 429 (non-unrecoverable) or a transport
error can now be auto-retried via StreamClientOptions.setRetry(RetryConfig).
Disabled by default: one attempt, errors surface unchanged. Retry lives in
StreamRequest.execute() as a loop around a fresh OkHttp Call per attempt
(not an interceptor), so each attempt gets its own callTimeout budget.
* test: skip HardDeleteChannels on async task timeout instead of failing
testHardDeleteChannels polls an async hard-delete task via waitForTask, but under shared-backend async-queue latency it times out (StreamTransportException after PT1M) and fails. Catch the transport timeout and abort (skip) the test, mirroring the getstream-go/php/ruby fix; a genuine task failure throws StreamTaskException and still fails.
Copy file name to clipboardExpand all lines: README.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,14 +114,31 @@ Four events are emitted:
114
114
|`client.initialized`| INFO | once, at client construction (SDK name/version and the effective client config) |
115
115
|`http.request.sent`| DEBUG | before each request (method, path, query) |
116
116
|`http.response.received`| DEBUG | after any response, including 4xx/5xx (status code, body size, duration) |
117
-
|`http.request.failed`| ERROR | transport failure only, when no HTTP response was received (error type, message, duration) |
117
+
|`http.request.failed`| ERROR / DEBUG | ERROR on a final transport failure (no HTTP response received; error type, message, duration). DEBUG once per attempt that gets retried (see [Retry](#retry)); a retried rate-limit (429) DEBUG log omits the error type field, since it isn't a transport error.|
118
118
119
119
Redaction is mandatory and cannot be disabled: query values for `api_key`, `api_secret` and `token` are replaced with `<redacted>`, and the top-level JSON body keys `api_secret`, `token` and `password` are redacted. The events never log request/response headers.
120
120
121
121
Request and response bodies are **not** logged by default. Call `StreamClientOptions.setLogBodies(true)` to opt in (secret body keys are still redacted); doing so emits a one-time warning at construction. Do not enable body logging in production unless you accept the risk of logging sensitive payloads.
122
122
123
123
> **Deprecated:** the older `HttpLoggingInterceptor` is deprecated in favour of these SLF4J events. It is kept for backward compatibility and now redacts secret headers and secret body keys in its own output.
124
124
125
+
### Retry
126
+
127
+
Auto-retry is **opt-in** and disabled by default: the client makes exactly one attempt and surfaces errors unchanged. Enable it via `StreamClientOptions.setRetry(...)`:
var client =newStreamSDKClient("apiKey", "apiSecret", options);
138
+
```
139
+
140
+
Only idempotent `GET`/`HEAD` requests are retried, and only for HTTP 429 (rate limited, unless the server marked it unrecoverable) or a transport-level failure (connection reset, timeout, DNS failure, TLS handshake failure). Writes (`POST`/`PUT`/`PATCH`/`DELETE`) and any other 4xx/5xx response are never retried. The delay before each retry honors the `Retry-After` header when present (clamped to `MaxBackoff`); otherwise it uses full-jitter exponential backoff. When attempts are exhausted, the last attempt's error is surfaced.
141
+
125
142
## Development
126
143
127
144
To run tests, create the `local.properties` file using the `local.properties.example` and adjust it to have valid API credentials:
0 commit comments