aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
978 stars 624 forks source link

Request timeout transient error #28

Closed revmischa closed 8 years ago

revmischa commented 8 years ago

I'm using the new 2.0 API. When I call aws_iot_shadow_connect() sometimes it returns with error -28 (MQTT_REQUEST_TIMEOUT_ERROR I believe) and sometimes it succeeds just fine. I'm on a good internet connection, although thousands of miles away from the endpoint right now so maybe there's some latency, but it should still connect ok.

Maybe you can look at my code and tell me what I'm doing wrong, or maybe it's a bug? I don't believe this was happening in version 1.1.2 previously.

Code: https://github.com/revmischa/cloudcam/blob/master/src/iot.c#L54

chaurah commented 8 years ago

Hi @revmischa, I believe this might be due to the mqttCommandTimeout specified in shadow connect. We were using 2000 ms as the timeout but you might have to set it higher. We have standardized on using 20000 ms from the next release onwards, try using that value. You can modify it here - https://github.com/aws/aws-iot-device-sdk-embedded-C/blob/master/src/aws_iot_shadow.c#L66

This does neatly flow into your other suggestion of allowing user to set the connect parameters. We are looking into including that in the next release. It will be a breaking change if we suddenly remove the hardcoding, but it does need to be done at some point :)

As always, please feel free to let us know if you find more issues

Rahul

chaurah commented 8 years ago

Hi @revmischa, Default timeouts have been increased to 20 secs for samples now. Hopefully this would prevent the issue from recurring. Please let us know if you have any further suggestions.

Rahul