【发布时间】:2020-08-07 06:26:31
【问题描述】:
我一直在尝试从 https://github.com/awslabs/aws-sdk-ios-samples/tree/master/IoT-Sample/Swift 运行 AWS IOS IoT 示例。但是,当我单击应用程序中的“连接”按钮时,出现以下错误。 MQTT 连接失败。我该如何解决这个问题?
2019-08-20 20:19:29:065 IoTSampleSwift[87568:16809125] Attempting to
reconnect.
connection status = 1
Connecting...
2019-08-20 20:19:29:065 IoTSampleSwift[87568:16809125] user metadata is : ?SDK=iOS&Version=2.10.2
2019-08-20 20:19:29:065 IoTSampleSwift[87568:16809125] Metrics collection is: Enabled
2019-08-20 20:19:29:066 IoTSampleSwift[87568:16809130] <<<NSThread: 0x6000029d2500>{number = 9, name = (null)}>> Initializing MQTTEncoder and MQTTDecoder streams
2019-08-20 20:19:29:066 IoTSampleSwift[87568:16809130] opening encoder stream.
2019-08-20 20:19:29:067 IoTSampleSwift[87568:16809130] opening decoder stream.
2019-08-20 20:19:29.067789-0700 IoTSampleSwift[87568:16809130] CFNetwork SSLHandshake failed (-9810)
2019-08-20 20:19:29.067943-0700 IoTSampleSwift[87568:16809130] TCP Conn 0x0 SSLHandshake failed (-9810)
2019-08-20 20:19:29:068 IoTSampleSwift[87568:16809130] MQTT session error, code: 3
2019-08-20 20:19:29:068 IoTSampleSwift[87568:16809130] closing encoder stream.
2019-08-20 20:19:29:068 IoTSampleSwift[87568:16809130] closing decoder stream.
2019-08-20 20:19:30:071 IoTSampleSwift[87568:16809130] MQTTSessionEventConnectionError: Received an MQTT session connection error
connection status = 5
Connection Error
我的 IoT 政策如下所示:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:*",
"Resource": "*"
}
]
}
我的 Unauth Cognito 角色如下所示:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*",
"cognito-identity:*",
"dynamodb:*",
"cloudwatch:*",
"events:*",
"iot:GetThingShadow",
"iot:UpdateThingShadow",
"iot:Subscribe",
"iot:Connect",
"iot:AttachPrincipalPolicy",
"iot:CreateKeysAndCertificate",
"iot:CreateCertificateFromCsr"
],
"Resource": [
"*"
]
}
]
}
【问题讨论】:
-
您能否分享有关您用于连接的代码和您正在连接的 IoT Core 上的应用程序的更多详细信息?可能是这方面的错误配置。