|
272 | 272 | - `retry-ms-fn` unary fn called with the current attempt at reconnecting, starting at 1. It must return a numer of |
273 | 273 | milliseconds to wait before retrying a new connection, or nil to close the reconnector. Defaults to 5000 (5 secs). |
274 | 274 | - `on-error-retry-fn?` unary fn called with error when creating a new connection. Must return true to start a retry |
275 | | - timeout to retry, otherwise the reconnector will be closed. Note: It is called with the original Exception unwrapped, |
276 | | - which will probably be an ExecutionException from the CompletableFuture returned by creating a new Websocket in JDK11. |
277 | | - You might want to get the wrapped exception for more details `(ex-cause <error>)`. Defaults to returning true |
278 | | - when the wrapped exception is a java.net.ConnectException, false otherwise." |
| 275 | + timeout to retry, otherwise the reconnector will be closed. |
| 276 | + Note: It is called with the original Exception unwrapped, which will be an ExecutionException from the |
| 277 | + CompletableFuture returned by creating a new Websocket in JDK11. You might want to get the wrapped exception for |
| 278 | + more details `(ex-cause <error>)`. Defaults to returning logical true when the wrapped exception is either a |
| 279 | + java.net.ConnectException or java.net.http.HttpTimeoutException, false otherwise." |
279 | 280 | [{:keys [retry-ms-fn on-error-retry-fn? get-url get-opts] |
280 | 281 | :or {retry-ms-fn (constantly 5000) |
281 | | - on-error-retry-fn? (fn [err] (instance? ConnectException (ex-cause err))) |
| 282 | + on-error-retry-fn? (fn [err] |
| 283 | + (let [ex (ex-cause err)] |
| 284 | + (or (instance? java.net.ConnectException ex) |
| 285 | + (instance? java.net.http.HttpTimeoutException ex)))) |
282 | 286 | get-opts (constantly nil)}}] |
283 | 287 | (let [connections (a/chan) |
284 | 288 | close (a/promise-chan)] |
|
0 commit comments