首页 > 解决方案 > 如何设置 AWSIoTManager 的自动重连尝试次数

问题描述

如何设置 AWSIoTManager 的自动重新连接尝试次数和重试限制?

这是Java示例:

aWSIotMqttManager = AWSIotMqttManager(..)
aWSIotMqttManager.maxAutoReconnectAttempts = 1
aWSIotMqttManager.setReconnectRetryLimits(1, 4)

标签: iosamazon-web-servicesaws-sdkaws-iot

解决方案


您可以在aws-sdk-ios注册时为每个服务提供配置(如AWSIoTManager所示)

AWSServiceConfiguration 继承自 AWSNetworkingConfiguration,它具有以下属性maxRetryCount

失败请求的最大重试次数。该值需要介于 0 和 10(含)之间。如果设置为高于 10,则变为 10。

例如(迅速):

let configuration = AWSServiceConfiguration(maxRetryCount: 7)
AWSIoTManager.register(with: configuration!, forKey: "USWest2IoTManager")

推荐阅读