The trouble I am facing is hard to debug as it doesn't offer much of an explanation in the stack trace. What I am trying to do is retrieve an oAuth token using a key and a secret provided to me. When using postman it works just fine meaning the issue cannot be external. When I try it in Clojure it fails.
See sample code below.
(let [options {:keepalive 10000
:timeout 10000
:query-params {:grant_type "client_credentials"}
:headers {"Authorization" (str "Basic " (-> (str (:key config/oAuth) ":" (:secret config/oAuth)) .getBytes b64/encode String. ))}
}]
@(http/get "https://my-path.com/oauth/v1/generate" options))
the result I get is
1. Unhandled java.io.IOException
An existing connection was forcibly closed by the remote host
SocketDispatcher.java: -2 sun.nio.ch.SocketDispatcher/read0
SocketDispatcher.java: 43 sun.nio.ch.SocketDispatcher/read
IOUtil.java: 223 sun.nio.ch.IOUtil/readIntoNativeBuffer
IOUtil.java: 197 sun.nio.ch.IOUtil/read
SocketChannelImpl.java: 379 sun.nio.ch.SocketChannelImpl/read
HttpsRequest.java: 93 org.httpkit.client.HttpsRequest/doHandshake
HttpClient.java: 133 org.httpkit.client.HttpClient/doRead
HttpClient.java: 377 org.httpkit.client.HttpClient/run
Thread.java: 745 java.lang.Thread/run
IOException java.io.IOException: An existing connection was forcibly closed by the remote host
Below is the curl request sample generates
curl -X GET 'https://my-path.com/oauth/v1/generate' -H 'authorization: Basic Nasjdbajksdkasjdkey:secret==' -H 'cache-control: no-cache' -H 'postman-token: f2af6f4a-f197-20df-f9be-a5a9a7525e57'
I have obviously changed any sensitive information. Now the strange thing is that when I run that curl request it doesn't work despite postman returning expected results. See curl error below
* Adding handle: conn: 0x1328a58
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1328a58) send_pipe: 1, recv_pipe: 0
* About to connect() to my-path.com port 443 (#0)
* Trying xxx.xxx.xxx.xxx...
* Connected to my-path.com (xxx.xxx.xxx.xxx) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: E:\Git\bin\curl-ca-bundle.crt
CApath: none
* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to my-path.com:443
* Closing connection 0
curl: (35) Unknown SSL protocol error in connection to my-path.com:443
Why does it work on postman but not for the exact curl request postman generated?
Why does it not work for my Clojure app, any assistance will be greatly appreciated.