Reputation: 43
I am trying to run a script to connect to a iot topic on aws which has a custome message callback but the connection wont take place and throws the error mentioned in the question
This is for raspberry pi that uses aws iot for subscribing to a topic and receiving the custom message i have checked the endpoint its correct i have given only the partial code below
# Custom MQTT message callback
def photoVerificationCallback(client, userdata, message):
print("Received a new message: ")
data = json.loads(message.payload)
try:
similarity = data[1][0]['Similarity']
print("Received similarity: " + str(similarity))
if(similarity >= 90):
print("Access allowed, opening doors.")
print("Thank you!")
except:
pass
print("Finished processing event.")
def checkRFIDNumber(rfidnumber):
return rfidnumber == '0004098554'
# Connect and subscribe to AWS IoT
myAWSIoTMQTTClient.connect()
myAWSIoTMQTTClient.subscribe("rekognition/result", 1,
photoVerificationCallback)
time.sleep(2)
# Publish to the same topic in a loop forever
while True:
print("waiting..")
scan = waitForRFIDScan()
print(scan)
if(checkRFIDNumber(scan)):
print("RFID correct, taking photo...")
uploadToS3(scan)
else:
print("Bad RFID - Access Denied")
Upvotes: 1
Views: 3532
Reputation: 43
The issue was not in the program it was in the configuration on the aws side once i fixed the policy it started working
i had to fix my iot policy that attaches to the certificates with iot:* for actions
Upvotes: 2