如何修复 AWSIoTPythonSdk.exception.AWSIoTException.subscribeTimeoutException

How to fix AWSIoTPythonSdk.exception.AWSIoTException.subscribeTimeoutException

我正在尝试 运行 一个脚本来连接到 aws 上的物联网主题,该主题具有客户消息回调,但连接不会发生并抛出问题中提到的错误

这是针对 raspberry pi 的,它使用 aws iot 订阅主题并接收自定义消息 我已经检查了端点是否正确 我只给出了下面的部分代码

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

问题不在程序中,它在 aws 端的配置中,一旦我修复了它开始工作的策略

我必须修复附加到证书的物联网政策 iot:* 用于操作