我想在AWS上连接到我客户端的MQTT服务。我找到了这个Amazon IoT Sample,这节省了我花费大量时间来挖掘API以找到连接AWS MQTT服务的过程。
在我的项目中,我更改了Constants.swift
中的常量以访问我的客户端的MQTT服务,如下所示:
let AWSRegion = AWSRegionType.USWest2 // e.g. AWSRegionType.USEast1
let CognitoIdentityPoolId = "us-west-2:e95087f0-48a7-4732-b482-4614c7c63db6"
let CertificateSigningRequestCommonName = "MyApp"
let CertificateSigningRequestCountryName = "MyCountry"
let CertificateSigningRequestOrganizationName = "MyOrganization"
let CertificateSigningRequestOrganizationalUnitName = "MyUnit"
let PolicyName = "pubsub_policy"
// This is the endpoint in your AWS IoT console. eg: https://xxxxxxxxxx.iot.<region>.amazonaws.com
let IOT_ENDPOINT = "https://<endpoint>.amazonaws.com" // endpoint is entered correctly!
let ASWIoTDataManager = "MyIotDataManager"
但是当我按Connect
时,应用会抛出此错误:
2018-06-04 17:12:59:992 IoTSampleSwift [4999:2464150]回复正文: {“__ type”:“InvalidIdentityPoolConfigurationException”,“message”:“无效的标识池配置。检查此池的已分配的IAM角色。”}
2018-06-04 17:12:59:994 IoTSampleSwift [4999:2464150] GetCredentialsForIdentity失败。错误是[错误 Domain = com.amazonaws.AWSCognitoIdentityErrorDomain Code = 5“(null)” 的UserInfo = {__类型= InvalidIdentityPoolConfigurationException, message =无效的标识池配置。检查分配的IAM角色 这个游泳池。}]
2018-06-04 17:12:59:995 IoTSampleSwift [4999:2464150] 无法刷新。错误是[错误 Domain = com.amazonaws.AWSCognitoIdentityErrorDomain Code = 5“(null)” 的UserInfo = {__类型= InvalidIdentityPoolConfigurationException, message =无效的标识池配置。检查分配的IAM角色 这个游泳池。}]
2018-06-04 17:13:00:017 IoTSampleSwift [4999:2464150] 错误:错误Domain = com.amazonaws.AWSCognitoIdentityErrorDomain Code = 5 “(null)”UserInfo = {__ type = InvalidIdentityPoolConfigurationException, message =无效的标识池配置。检查分配的IAM角色 这个游泳池。}
Constants.swift
中的参数有问题吗? 很抱歉,我不得不问这些简单的问题,因为我是AWS IoT API的新手。
此致
答案 0 :(得分:0)