Fork me on GitHub
#aws
<
2020-12-11
>
viesti11:12:36

error sounds like xml stuff landing where json expected, wonder if kinesis-video-media wire format is supported via aws-api 😬

viesti12:12:09

sometimes hard to cook one up, but maybe a small reproducible example would help

dabrazhe19:12:53

Sure, perhaps you will see what I am missing. The aws-cli command works fine.

aws kinesis-video-media get-media --stream-arn "arn:aws:kinesisvideo:eu-west-1:9000ACCOUNT:stream/camera1/1607464961761" --start-selector StartSelectorType="NOW" --p devpl2 --endpoint-url "" cam.mkv

dabrazhe19:12:06

I am able to invoke on the :kinesisvideo client and get Endpoint and StreamArn without any issues. To read from the stream I am creating a :kinesis-video-media client, which is created fine.

(def kvmedia (aws/client {:api :kinesis-video-media :region "eu-west-1" :endpoint kvs-endpoint :credentials-provider (cred/profile-credentials-provider "devpl2")}))

dabrazhe19:12:09

What breaks is invoke on the :kinesis-video-media client. Whatever I invoke with results in the cryptic json error.

(aws/invoke kvmedia {:op :GetMedia 
    :request {:StartSelector {:StartSelectorType "EARLIEST"}
                               :StreamARN stream-arn}})

dabrazhe19:12:16

The json error

{:cognitect.anomalies/category :cognitect.anomalies/fault,
 :cognitect.aws.client/throwable
   #error
    {:cause "JSON error (unexpected character): <",
     :trace
       [[clojure.data.json$_read invokeStatic "json.clj"
         230]
        [clojure.data.json$_read invoke "json.clj" 181]
        [clojure.data.json$read invokeStatic "json.clj" 276]
        [clojure.data.json$read doInvoke "json.clj" 232]
        [clojure.lang.RestFn applyTo "RestFn.java" 139]
        [clojure.core$apply invokeStatic "core.clj" 667]
        [clojure.core$apply invoke "core.clj" 660]
        [clojure.data.json$read_str invokeStatic "json.clj"
         282]
        [clojure.data.json$read_str doInvoke "json.clj" 278]
        [clojure.lang.RestFn invoke "RestFn.java" 439]
        [cognitect.aws.protocols.common$json_parse_error
         invokeStatic "common.clj" 42]
        [cognitect.aws.protocols.common$json_parse_error
         invoke "common.clj" 40]
        [cognitect.aws.protocols.rest$parse_http_response
         invokeStatic "rest.clj" 261]
        [cognitect.aws.protocols.rest$parse_http_response
         invoke "rest.clj" 249]
        [cognitect.aws.protocols.rest_json$eval32496$fn__32497
         invoke "rest_json.clj" 61]
        [clojure.lang.MultiFn invoke "MultiFn.java" 239]
        [cognitect.aws.client$handle_http_response
         invokeStatic "client.clj" 48]
        [cognitect.aws.client$handle_http_response invoke
         "client.clj" 43]
        [cognitect.aws.client$send_request$fn__12219$state_machine__6619__auto____12246$fn__12249
         invoke "client.clj" 111]
        [cognitect.aws.client$send_request$fn__12219$state_machine__6619__auto____12246
         invoke "client.clj" 107]
        [clojure.core.async.impl.ioc_macros$run_state_machine
         invokeStatic "ioc_macros.clj" 978]
        [clojure.core.async.impl.ioc_macros$run_state_machine
         invoke "ioc_macros.clj" 977]
        [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped
         invokeStatic "ioc_macros.clj" 982]
        [clojure.core.async.impl.ioc_macros$run_state_machine_wrapped
         invoke "ioc_macros.clj" 980]
        [clojure.core.async.impl.ioc_macros$take_BANG_$fn__6637
         invoke "ioc_macros.clj" 991]
        [clojure.core.async.impl.channels.ManyToManyChannel$fn__623$fn__624
         invoke "channels.clj" 95]
        [clojure.lang.AFn run "AFn.java" 22]
        [java.util.concurrent.ThreadPoolExecutor runWorker
         "ThreadPoolExecutor.java" 1135]
        [java.util.concurrent.ThreadPoolExecutor$Worker run
         "ThreadPoolExecutor.java" 635]
        [clojure.core.async.impl.concurrent$counted_thread_factory$reify__492$fn__493
         invoke "concurrent.clj" 29]
        [clojure.lang.AFn run "AFn.java" 22]
        [java.lang.Thread run "Thread.java" 844]],
     :via [{:at [clojure.data.json$_read invokeStatic
                 "json.clj" 230],
            :message "JSON error (unexpected character): <",
            :type java.lang.Exception}]}}

lukasz22:12:46

Just guessing here - since it starts with < - that means you're getting an XML/HTML response?

lukasz22:12:01

You can bump logging level of the underlying http client and see if that helps

dabrazhe21:12:05

That's the whole errors I am getting in response. What do you meany by logging level by the client?

lukasz22:12:44

if you're using clojure.tools.logging and switch the log level from info to debug, you'll see debug logs from the underlying HTTP client (I believe it's based on Jetty) - this way you'll see all of the request details

dabrazhe19:12:00

The json error is in the thread. I even found the boto3 api for :kinesis-video-media and it seems like I am doing things in the same way.