aleph

2020-10-12T15:31:41.002800Z

Anyone know why I might be getting 400 errors with aleph's http client, when clj-http gives a 200 response for the same request? It's just a basic get request with no params

2020-10-12T17:37:50.003700Z

Could be anything I guess, missing query params, authentication. Can you share the request map?

2020-10-12T17:42:16.005100Z

Just a basic get on a public endpoint with no params

;;clj-http works as expected:
(clj-http/get "<https://api-public.sandbox.pro.coinbase.com/products/BTC-USD/ticker>"
  {:debug       true
   :debug-body? true
   :as :json})

@(aleph-http/get "<https://api-public.sandbox.pro.coinbase.com/products/BTC-USD/ticker>"
   {:debug true
    :debug-body? true
    :as :json})
;;=&gt;
{:aleph/keep-alive? true,
    :aleph/complete #object[manifold.deferred.SuccessDeferred
                            "0x7397ac1"
                            {:status :ready, :val false}],
    :headers {"server" "cloudflare",
              "content-type" "application/json; charset=utf-8",
              "content-length" "44",
              "connection" "keep-alive",
              "cf-request-id" "05bf7ff214000091da2324c200000001",
              "set-cookie" "__cfduid=d66496ec04481eff43488e02e22fcad141602524469; expires=Wed, 11-Nov-20 17:41:09 GMT; path=/; domain=.<http://sandbox.pro.coinbase.com|sandbox.pro.coinbase.com>; HttpOnly; SameSite=Lax; Secure",
              "expect-ct" "max-age=604800, report-uri=\"<https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct>\"",
              "cf-cache-status" "EXPIRED",
              "cf-ray" "5e129c302f8691da-EWR",
              "date" "Mon, 12 Oct 2020 17:41:09 GMT"},
    :status 400,
    :body #object[java.io.ByteArrayInputStream
                  "0x5d066dd"
                  "java.io.ByteArrayInputStream@5d066dd"]}{:aleph/keep-alive? true,
    :aleph/complete #object[manifold.deferred.SuccessDeferred
                            "0x7397ac1"
                            {:status :ready, :val false}],
    :headers {"server" "cloudflare",
              "content-type" "application/json; charset=utf-8",
              "content-length" "44",
              "connection" "keep-alive",
              "cf-request-id" "05bf7ff214000091da2324c200000001",
              "set-cookie" "__cfduid=d66496ec04481eff43488e02e22fcad141602524469; expires=Wed, 11-Nov-20 17:41:09 GMT; path=/; domain=.<http://sandbox.pro.coinbase.com|sandbox.pro.coinbase.com>; HttpOnly; SameSite=Lax; Secure",
              "expect-ct" "max-age=604800, report-uri=\"<https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct>\"",
              "cf-cache-status" "EXPIRED",
              "cf-ray" "5e129c302f8691da-EWR",
              "date" "Mon, 12 Oct 2020 17:41:09 GMT"},
    :status 400,
    :body #object[java.io.ByteArrayInputStream
                  "0x5d066dd"
                  "java.io.ByteArrayInputStream@5d066dd"]}

2020-10-12T17:43:27.005700Z

could it be related to SSL config?

mccraigmccraig 2020-10-12T17:47:33.007400Z

i suspect probably not ssl config, since you are getting an http 400 back. what's in that :body ByteArrayInputStream ? there might a useful error description in there...

2020-10-12T17:56:38.007800Z

Ah!

"{\"message\":\"User-Agent header is required.\"}"
that explains it. Thanks for the help!

mccraigmccraig 2020-10-12T18:24:55.008100Z

yw!

euccastro 2020-10-12T21:51:49.009200Z

yes, clj-http and other libraries that try and imitate that do supply a "User-Agent" on their own. bit me when porting code from that to Aleph