AWS IoT Topic Rule Empty JSON Array BUG

0

Hello,

I think i've encountered a bug within the IoT Core topic rules. We have the following topic which invokes a lambda:
'+/select'

In our topic rule we've defined the following statement:
"SELECT *, topic(1) as machineId FROM '+/select'"

Then we send the following mqtt message to the topic:
{
"slots":[1,2,3],
"session-id":"abcd"
}

However, when we get the event in the lambda the array is empty so the event looks as follows:
{
"slots":[],
"session-id":"abcd",
"machineId":"123456"
}

How can we make it that the slots array isn't emptied?

Thank you

Inspiro
已提問 4 年前檢視次數 385 次
3 個答案
0
已接受的答案

Hi,

I've encountered the same problem with an IOT rule created with CloudFormation which set the sql version to "SQL version 2015-10-08".
Editing the IOT rule and selecting "SQL version 2016-03-23" resolved it.

Regards,
Hubert

已回答 3 年前
profile picture
專家
已審閱 1 個月前
0

Hello Inspiro,
Thank you for reaching out!
I think maybe you missed quotes around https://forums.aws.amazon.com/?
I created a rule with the sql you provided, and when I published the following payload, my lambda received the correct event.

publishing
{
"slots":"https://forums.aws.amazon.com/",
"session-id":"abcd"
}

lambda logged:
{
"slots": "https://forums.aws.amazon.com/",
"session-id": "abcd",
"machineId": "12345"
}

Hope it helps.

AWS
已回答 4 年前
0

Hello XinYiAtAWS ,

Thank you for your response.

I see now that i've made a typo in my question. The mqtt body i send is as follows:

{
"slots":[],
"session-id":"abcd"
}
Where the slots array is filled with integers. (Aparantly aws forums changes my array of integers to a link)

When we the topic rule is executed i receive the following event in the lambda.
{
"slots":[],
"session-id":"abcd",
"machineId":"123456"
}
Here i need the integers in the array just as with the request above.

Do you know what the problem could be?

Edited by: Inspiro on Oct 5, 2020 12:35 AM

Inspiro
已回答 4 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南