aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
978 stars 625 forks source link

jobs demo mosquito unable to execute job #1808

Closed avrono closed 2 years ago

avrono commented 2 years ago

running the jobs_mosquitto_demo application. The application fails with missing url despite following for example the instructions here

https://docs.aws.amazon.com/iot/latest/developerguide/iot-dc-runjobs-prepare-define.html

Believe I have the correct Policy as described here https://docs.aws.amazon.com/iot/latest/developerguide/basic-jobs-example.html

Please advise ....

jasonpcarroll commented 2 years ago

Hi @avrono, Thank you for reaching out. I will look into this. Could you post logs of your error and let me know what version of the repository you are using? Best, Jason Carroll

avrono commented 2 years ago

Hi Jason,

I am using 202108.00

Also note that I tried the job client in the aws-iot-device-client repo (C++ SDK) and that works as expected.

jobs_demo_mosquitto: Connecting to xxxxxx-ats.iot.eu-west-2.amazonaws.com, port 8883. jobs_demo_mosquitto: Client AvronMac-2 sending CONNECT jobs_demo_mosquitto: Client AvronMac-2 received CONNACK (0) jobs_demo_mosquitto: Client AvronMac-2 sending SUBSCRIBE (Mid: 1, Topic: $aws/things/AvronMac-2/jobs/notify-next, QoS: 1, Options: 0x00) jobs_demo_mosquitto: Client AvronMac-2 received SUBACK jobs_demo_mosquitto: requesting first job jobs_demo_mosquitto: Client AvronMac-2 sending PUBLISH (d0, q1, r0, m2, '$aws/things/AvronMac-2/jobs/$next/get', ... (0 bytes)) jobs_demo_mosquitto: Client AvronMac-2 received PUBACK (Mid: 2, RC:0) jobs_demo_mosquitto: Client AvronMac-2 received PUBLISH (d0, q0, r0, m0, '$aws/things/AvronMac-2/jobs/$next/get/accepted', ... (24 bytes)) jobs_demo_mosquitto: Client AvronMac-2 received PUBLISH (d0, q1, r0, m1, '$aws/things/AvronMac-2/jobs/notify-next', ... (222 bytes)) jobs_demo_mosquitto: Client AvronMac-2 sending PUBACK (m1, rc0) jobs_demo_mosquitto: missing url; failing job id: s3-TEST8 jobs_demo_mosquitto: Client AvronMac-2 sending PUBLISH (d0, q1, r0, m3, '$aws/things/AvronMac-2/jobs/s3-TEST8/update', ... (19 bytes)) jobs_demo_mosquitto: Client AvronMac-2 received PUBACK (Mid: 3, RC:0) jobs_demo_mosquitto: Client AvronMac-2 received PUBLISH (d0, q0, r0, m0, '$aws/things/AvronMac-2/jobs/s3-TEST8/update/accepted', ... (24 bytes)) jobs_demo_mosquitto: job update success jobs_demo_mosquitto: Client AvronMac-2 received PUBLISH (d0, q1, r0, m1, '$aws/things/AvronMac-2/jobs/notify-next', ... (24 bytes)) jobs_demo_mosquitto: Client AvronMac-2 sending PUBACK (m1, rc0) jobs_demo_mosquitto: exit on signal: 2 jobs_demo_mosquitto: Client AvronMac-2 sending DISCONNECT

avrono commented 2 years ago

@jasonpcarroll any word on this ?

paulbartell commented 2 years ago

@avrono : My apologies for the delayed reply to your inquiry.

The best reference material for the jobs_mosquitto demo is the IoT C-SDK documentation page detailing it.

While AWS IoT Jobs in general are not required to have a url parameter, this particular demo expects the url parameter to always be present so that the demo can download the file referenced by the url.

In short, to create a job that can be processed by this demo, run the following awscli command:

aws iot create-job --job-id t12 --targets arn:aws:iot:us-east-1:1234567890:thing/device1 \
  --document '{"url":"https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.8.5.tar.xz"}'

You can change this behavior by modifying the jobs_demo_mosquitto.c file according to your own needs.