Got connection refused exception
Closed this issue · 2 comments
vganshin commented
Hello. I faced a little issue with clj-http "3.11.0".
I set up :throw-exceptions
to false and try to send request to stopped service on http://localhost:8080 and I got Connection refused exception.
(ns user
(:require [clj-http.client :as http]))
(http/request
{:url "http://localhost:8080"
:ignore-unknown-host? true
:redirect-strategy :none
:throw-exceptions false})
Few more samples:
;; Example from README
(http/get "http://example.invalid" {:ignore-unknown-host? true}) ;; => nil
(http/get "http://localhost:8080" {:ignore-unknown-host? true}) ;; Exception: Connection refused
(http/get "https://little.aidbox.app:1234" {:ignore-unknown-host? true}) ;; Exception: Operation timed out
rymndhng commented
Hey @vganshin, the behavior you're describing is expected of clj-http
.
The option :throw-exceptions
does not swallow all exceptions. It only changes the response handling behaviour when the status code is 4xx and 5xx.
vganshin commented
Oh, I got it. Thanks.