Commit 6cfd64d
feat: opt out of ReconnectingWebSocketListener wrapper, auto-disable for custom transports
Adds `ClientOptions.Builder.reconnect(boolean)` (default `true`). When
`false`, the per-resource WebSocket clients (`listen/v1`, `listen/v2`,
`agent/v1`, `speak/v1`) connect once via a plain `okhttp3.WebSocketListener`
and propagate failures directly, bypassing `ReconnectingWebSocketListener`
and its hardcoded `connectionFuture.get(4000, MILLISECONDS)` ceiling.
Auto-disable for custom transports: when
`DeepgramClientBuilder.transportFactory(...)` (or its async counterpart)
is set, `setAdditional()` now also calls `builder.reconnect(false)`.
Custom transports like `SageMakerTransportFactory` already manage their
own connection lifecycle and retry semantics; wrapping them in another
retry layer creates double-retry storms under burst load.
The four per-resource WebSocket client files are added to the
"temporarily frozen" section of `.fernignore` so the patch survives the
next Fern regen. Unfreeze once the change has been pushed upstream into
the Fern generator template.
Backwards compatibility:
- Existing callers that do NOT use `transportFactory(...)` see zero
behavior change. `reconnect()` defaults to `true`, the
`ReconnectingWebSocketListener` wrapper is unchanged for the OkHttp
WebSocket path (Deepgram cloud, self-hosted Deepgram via raw WS),
and the lower-level `ClientOptions.Builder.webSocketFactory(...)`
seam is also unaffected.
- Existing SageMaker callers (the only known users of
`transportFactory(...)`) get the auto-disable. Empirically this
eliminates the retry-storm pattern observed at 400 concurrent
streams on a 10x ml.g6.2xlarge endpoint:
ThrottlingException line-count 68,909 -> 240 (-99.7%)
ModelStreamError line-count 30,442 -> 1,128 (-96.3%)
Streams hitting Attempt Count: 4 29,030 -> 96 (-99.7%)
4-second `connection timeout` 13 -> 0
Total error log lines 1,322,666 -> 33,972 (-97.4%)
Same wall time (313 vs 312 s), same transcript count, dramatically
cleaner error log.
Edge case worth calling out:
- A SageMaker caller who has been tuning retry behavior via
`wsClient.reconnectOptions(customOpts)` will find those options
silently ignored after this change (`reconnect=false` skips the
listener entirely). Their tuning was almost certainly a workaround
for the very storm we are now eliminating, so the right migration
is to delete the `reconnectOptions(...)` call. Customers who
genuinely want both a custom transport and SDK-side reconnect can
re-enable explicitly with `.reconnect(true)` after
`.transportFactory(...)`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c790dbd commit 6cfd64d
8 files changed
Lines changed: 364 additions & 24 deletions
File tree
- src/main/java/com/deepgram
- core
- resources
- agent/v1/websocket
- listen
- v1/websocket
- v2/websocket
- speak/v1/websocket
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | | - | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
109 | 125 | | |
110 | 126 | | |
111 | 127 | | |
| |||
127 | 143 | | |
128 | 144 | | |
129 | 145 | | |
| 146 | + | |
| 147 | + | |
130 | 148 | | |
131 | 149 | | |
132 | 150 | | |
| |||
187 | 205 | | |
188 | 206 | | |
189 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
190 | 219 | | |
191 | 220 | | |
192 | 221 | | |
| |||
220 | 249 | | |
221 | 250 | | |
222 | 251 | | |
223 | | - | |
| 252 | + | |
| 253 | + | |
224 | 254 | | |
225 | 255 | | |
226 | 256 | | |
| |||
235 | 265 | | |
236 | 266 | | |
237 | 267 | | |
| 268 | + | |
238 | 269 | | |
239 | 270 | | |
240 | 271 | | |
| |||
Lines changed: 81 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
| |||
144 | 151 | | |
145 | 152 | | |
146 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
147 | 206 | | |
148 | 207 | | |
149 | 208 | | |
| |||
201 | 260 | | |
202 | 261 | | |
203 | 262 | | |
204 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
205 | 269 | | |
206 | 270 | | |
207 | 271 | | |
| |||
300 | 364 | | |
301 | 365 | | |
302 | 366 | | |
303 | | - | |
304 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
305 | 373 | | |
306 | 374 | | |
307 | 375 | | |
| |||
501 | 569 | | |
502 | 570 | | |
503 | 571 | | |
504 | | - | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
505 | 576 | | |
506 | 577 | | |
507 | 578 | | |
| |||
514 | 585 | | |
515 | 586 | | |
516 | 587 | | |
517 | | - | |
518 | | - | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
519 | 594 | | |
520 | 595 | | |
521 | 596 | | |
| |||
0 commit comments