Rougher
Rougher

Reputation: 848

AWS JAVA IoT client reconnects every 10 minutes

I use IoT SDK in JAVA. When my application starts, it connects to IoT core of AWS:

iotClient = new AWSIotMqttClient(. . .);            
iotClient.connect();

But after application starting I see in my log a very strange behavior and it happens every 10 minutes:

[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>

How can I disable reconnection every 10 minutes? I use IoT Rules on CONNECTED/DISCONNECTED topic, so reconnection every 10 minutes fires this rule every 10 minutes...

Upvotes: -1

Views: 935

Answers (2)

Bluco
Bluco

Reputation: 11

Had the same issue, only on my EKS Kubernetes Cluster, but not on my local dev computer. I found out that the Default keepalive interval of the java lib is 600000ms or 10 minutes. This is not what some documentation declared.

The NAT used on my cluster has a fix Idle Timeout of 350 seconds. So the connection would drop.

I changed it to a lower value (like 30000ms).

iotClient.setKeepAliveInterval(30000);

For now this seems to work.

Upvotes: 1

Rougher
Rougher

Reputation: 848

I don't know why, but it is my solution:

iotClient = new AWSIotMqttClient(. . .);    
        
iotClient.setKeepAliveInterval(0);

iotClient.connect();

Upvotes: 0

Related Questions