Does anyone know why the following does not actually send a response to wscat
? I have tries all kinds of things for :Data which is supposed to be a blob
including (a json string, a json smile, a .getBytes of json string, a plain test string, and the object shown below)
(aws/invoke (aws/client {:api :apigatewaymanagementapi})
{:op :PostToConnection
:request {:Data {"action" "pong"}, :ConnectionId id}})
I get no errors at all
call (aws/doc client :PostToConnection)
PostToConnection
:op :PostToConnection
:request
{:Data blob, :ConnectionId string}
:required
[:ConnectionId :Data]
:response
nil
Sends the provided data to the specified connection.
{"action" "pong"} is not a blob
(aws/validate-requests client true)
then redo your request
is aws/validate-requests
something I call on the client that acts like a validate-requests!
or do I get a different client back. I tried the version where I get a client back, but it said the api was not implemented so I am assuming I just need to call it and it will change the state of the client.
As far as blobs go, I can't figure out how to make a blob that wscat
will understand, I just tried
(aws/invoke gw
{:op :PostToConnection
:request {:Data (bytes (byte-array (map (comp byte int) (json/generate-string {:action :pong})))), :ConnectionId id}})
and
(aws/invoke gw
{:op :PostToConnection
:request {:Data (bytes (byte-array (map (comp byte int) "test"))), :ConnectionId id}})
create the client, def it, call validate-requests on it, then use the client and it should throw a spec error when you give it an invalid blob
I will test giving it something bad now to make sure it throws errors. Both those do not give an error on the amazon side
Okay so I get no errors from the following for some reason:
(aws/validate-requests gw true)
(aws/invoke gw
{:op :PostToConnection
:request {:VeryBad {"a" "bad"}}})
will it be in the response to invoke maybe rather than thrown?
it might not complain if :Data is optional
give it {:Data 42}
and see what happens
It doesn't throw, but rather returns problems from the invocation call. After clearing up errors I am left with
(aws/invoke gw
{:op :PostToConnection
:request {:Data (byte-array (map (comp byte int) (json/generate-string {:action :pong})))
:ConnectionId id}})
Which produces:
"#:cognitect.anomalies{:category :cognitect.anomalies/not-found, :message \"<http://execute-api.us-east-1.amazonaws.com|execute-api.us-east-1.amazonaws.com>: No address associated with hostname\"}"
This leads me to believe {:api :apigatewaymanagementapi}
does not detect which deployment I am running, dev
in this case. Not sure where I would input this information or how to check if it does detect those things.I was following https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html when I decided to try and use apigatewaymanagementapi directly rather than create my own http posts.
@mail524 Did you look at what I posted in the #datomic channel? https://clojurians.slack.com/archives/C03RZMDSH/p1594910648214000