【发布时间】:2018-06-04 11:11:50
【问题描述】:
我想在 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 失败。错误是[错误 域=com.amazonaws.AWSCognitoIdentityErrorDomain 代码=5“(空)” UserInfo={__type=InvalidIdentityPoolConfigurationException, message=无效的身份池配置。检查分配的 IAM 角色 对于这个池。}]
2018-06-04 17:12:59:995 IoTSampleSwift[4999:2464150] 无法刷新。错误是[错误 域=com.amazonaws.AWSCognitoIdentityErrorDomain 代码=5“(空)” UserInfo={__type=InvalidIdentityPoolConfigurationException, message=无效的身份池配置。检查分配的 IAM 角色 对于这个池。}]
2018-06-04 17:13:00:017 IoTSampleSwift[4999:2464150] 错误:错误域 = com.amazonaws.AWSCognitoIdentityErrorDomain 代码 = 5 "(null)" UserInfo={__type=InvalidIdentityPoolConfigurationException, message=无效的身份池配置。检查分配的 IAM 角色 对于这个池。}
-
Constants.swift中的参数有问题吗? - 是否可以在我的客户服务中启用某些功能以便我可以访问?
- 根据10):p12 文件:如果可用,那么我每次需要访问这个MQTT 服务时不必动态创建密钥和证书?但是我的客户必须在他的Amazon AWS IoT Console 上创建它并给我证书/密钥,这样我才能在我的 MAC 上生成这个 p12 文件?
抱歉,由于我是 AWS IoT API 的新手,所以我不得不问这些简单的问题。
问候,
【问题讨论】:
标签: swift aws-sdk mqtt aws-iot