【发布时间】:2021-03-07 01:35:51
【问题描述】:
我在 JAVA 中使用 IoT SDK。当我的应用程序启动时,它会连接到 AWS 的 IoT 核心:
iotClient = new AWSIotMqttClient(. . .);
iotClient.connect();
但在应用程序启动后,我在日志中看到一个非常奇怪的行为,并且每 10 分钟发生一次:
[pool-8-thread-1] com.amazonaws.services.iot.client.core.AwsIotConnection.onConnectionSuccess Connection successfully established
[pool-8-thread-1] com.amazonaws.services.iot.client.core.AbstractAwsIotClient.onConnectionSuccess Client connection active: <client ID>
[pool-8-thread-1] com.amazonaws.services.iot.client.core.AwsIotConnection.onConnectionFailure Connection temporarily lost
[pool-8-thread-1] com.amazonaws.services.iot.client.core.AbstractAwsIotClient.onConnectionFailure Client connection lost: <client ID>
[pool-8-thread-1] com.amazonaws.services.iot.client.core.AwsIotConnection$1.run Connection is being retried
[pool-8-thread-1] com.amazonaws.services.iot.client.core.AwsIotConnection.onConnectionSuccess Connection successfully established
[pool-8-thread-1] com.amazonaws.services.iot.client.core.AbstractAwsIotClient.onConnectionSuccess Client connection active: <client ID>
如何禁用每 10 分钟重新连接一次?我在 CONNECTED/DISCONNECTED 主题上使用 IoT 规则,因此每 10 分钟重新连接会每 10 分钟触发一次此规则...
【问题讨论】:
-
每 10 分钟听起来可能是在网络级别清除长期连接。查看您的系统正在运行的网络。
-
你能提供更多细节吗?我到底需要检查什么?谢谢
-
你需要和你的网络管理员谈谈,看看路由器/防火墙是否有关于在一定时间限制后丢弃没有流量的连接的规则。
-
我使用带有默认固件的树莓派 - ufw。
-
这可能是它运行代码的地方,但这不会是您的站点/位置连接到实际互联网的方式
标签: java amazon-web-services mqtt aws-iot reconnect