aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
bamarco 2020-07-16T14:40:00.351600Z

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}})

bamarco 2020-07-16T14:40:31.352Z

I get no errors at all

ghadi 2020-07-16T14:40:43.352300Z

call (aws/doc client :PostToConnection)

bamarco 2020-07-16T14:41:21.353100Z

PostToConnection
:op :PostToConnection
:request
{:Data blob, :ConnectionId string}
:required
[:ConnectionId :Data]
:response
nil
Sends the provided data to the specified connection.

ghadi 2020-07-16T14:42:12.353700Z

{"action" "pong"} is not a blob

ghadi 2020-07-16T14:42:15.353900Z

(aws/validate-requests client true) then redo your request

bamarco 2020-07-16T15:23:27.357700Z

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}})

ghadi 2020-07-16T15:26:07.358500Z

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

bamarco 2020-07-16T15:27:16.359400Z

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

bamarco 2020-07-16T15:50:51.360600Z

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"}}})

bamarco 2020-07-16T15:51:52.361100Z

will it be in the response to invoke maybe rather than thrown?

ghadi 2020-07-16T15:52:49.361600Z

it might not complain if :Data is optional

ghadi 2020-07-16T15:53:03.362Z

give it {:Data 42} and see what happens

bamarco 2020-07-16T16:53:37.365200Z

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.

bamarco 2020-07-16T17:02:00.366400Z

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.

Joe Lane 2020-07-16T17:06:05.366900Z

@mail524 Did you look at what I posted in the #datomic channel? https://clojurians.slack.com/archives/C03RZMDSH/p1594910648214000

bamarco 2020-07-16T17:29:54.367800Z

@lanejo01 no! that is so much more specific to what i am trying to do. Thanks! Also thanks @ghadi

1