Open tobyloki opened 5 years ago
Try to add disconnect callback, maybe you will get info here:
sp.disconnectHandler = NULL;
@chegewara I tried doing that, but the callback was never triggered.
void disconnectCallback() {
printf("\n\nHI I am disconnected\n\n");
}
-----------------
sp.disconnectHandler = disconnectCallback;
@gearsmotion789 is your problem similar to this: https://github.com/aws/aws-iot-device-sdk-embedded-C/issues/161?
@shahpiyushv It could be possible, but I don't see a disconnect or reconnect according to the monitor - is there a way to modify the code so I could see this happening?
@shahpiyushv I believe that it is the same issue. I have changed keepAliveIntervalInSec from 600 to 65 in aws_iot_shadow.c and I no longer see this problem. However, I wanted to ask if there are any negatives to doing this (e.g more frequent polling of AWS IoT = more $$$ - see https://aws.amazon.com/iot-core/pricing/)? Is there a better solution than doing this?
@gearsmotion789 there is no impact on cost as AWS pricing is based on MQTT messages and connection time, not the exchange of keep-alive messages. Meanwhile, can you check for a slightly larger value, say 300 seconds?
@shahpiyushv Thanks. So I wanted to understand why this problem happened. It seems the device resets the keepAliveIntervalInSec (so it doesn't disconnect) whenever AWS IoT receives a PUBLISH, SUBSCRIBE, PING, or PUBACK message from the client according to https://github.com/awslabs/aws-iot-device-sdk-cpp-v2/issues/10. When does this happen in my code & at what interval? - why did it fail when keepAliveIntervalInSec = 600?
@gearsmotion789 , even I do not really understand why the issue occurs for 600 seconds and that too only on specific networks. If there is an issue with the network, which blocks the keep alive, it should have failed for any other interval as well.
Does anyone have any updates on this issue?
I've ran the thing_shadow example from https://github.com/espressif/esp-aws-iot/tree/master/examples/thing_shadow succesfully. However, after 5-10min of inactivity (meaning that I don't update the device shadow), the device doesn't respond to anymore changes to the shadow. I don't see that it disconnected from AWS on the monitor - so why is this happening and how can I fix this?
I've modified the code slightly so that it only sends a "reported" msg to the device shadow every time there is a delta change. It doesn't update the shadow itself every 1s like the original code.