Closed SOLR4189 closed 3 years ago
You can only have one client connected with each client id:
DUPLICATE_CLIENTID | The client is using a client ID that is already in use. In this case, the client that is already connected will be disconnected with this disconnect reason.
For example when you run the PubSub you need to have different -clientId sdk-java
. Because when creating a new AWSIotMqttClient you need to have different clientId's to avoid getting disconnected.
Please try fixing that and let me know if you are still getting any other disconnects (MQTT_KEEP_ALIVE_TIMEOUT)
Each client in my service has a unique CLIENT_ID and function "connect()" is called only once on device startup, so no way the client is using a client ID that is already in use.
Can you provide a minimum code sample that reproduces this? Also what devices and OS are you testing this on?
My code (it runs in tomcat on raspberry - OS buster):
iotClient = new AWSIotMqttClient(Configuration.IOT_CLIENT_ENDPOINT,
deviceId,
keyStore,
keystorePass);
iotClient.setKeepAliveInterval(1200000); // or iotClient.setKeepAliveInterval(0);
iotClient.connect();
I'll ask my question in an another way:
What I try to do is to get notifications when a device is connected/disconnected (by this method here)
Thanks
AWS IoT publishes a message to the following MQTT topics when a client connects or disconnects:
$aws/events/presence/connected/clientId – A client connected to the message broker.
$aws/events/presence/disconnected/clientId – A client disconnected from the message broker.
Gets the keep-alive interval for the MQTT connection in milliseconds currently configured. Setting this value to 0 will disable the keep-alive function for the connection. The default keep alive interval is 30,000ms.
I think you might be running into the max connection retries which is defaulted to 5. Use iotClient.setMaxConnectionRetries(x);
to set a higher number that will allow for longer periods of no connection.
Does this help solve your connection issues and timeouts?
Greetings! It looks like this issue hasn’t been active in longer than a week. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one, also please try V2 as this might be solved there too.
Hello, sorry for a delay.
I mean that my device sends logs over HTTPS every time, so it isn't internet issue.
I think, my client on device didn’t send (or can't send) any ping or MQTT control packets. PINGREQ is for this purpose to avoid disconnection whenever I set keep alive time interval. Maybe you know how can I check it? How can I set more detailed logs?
Thanks
You might want to check out Cloudwatch. When attaching logs make sure to redact all personal information.
Greetings! It looks like this issue hasn’t been active in longer than a week. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one, also please try V2 as this might be solved there too.
I use IoT Rules on CONNECTED/DISCONNECTED topic (from here). So I want to get email when a device is connected or disconnected. On my device I run next code on startup (only on startup):
But I get very strange behavior. I have 3 devices, and on each device I get this stacktrace but due to different reasons:
Sometimes I get this stacktrace due to DUPLICATE_CLIENTID disconnection reason, or sometimes due to MQTT_KEEP_ALIVE_TIMEOUT disconnection reason (MQTT_KEEP_ALIVE_TIMEOUT happens every 30-35 minutes, DUPLICATE_CLIENTID happens every 10 minutes)
So, I don't understand why do I need to deal with DUPLICATE_CLIENTID if each client has a unique ID, and to deal with MQTT_KEEP_ALIVE_TIMEOUT if there no an intermittent connectivity issue (I get logs every minute to my server, so it isn't WIFI/internet issue). I use the latest AWS IoT SDK from here - https://github.com/aws/aws-iot-device-sdk-java.
How can I solve these issues?