IoTHub raw messaging client sample using AMQP
Dependencies: iothub_client EthernetInterface NTPClient iothub_amqp_transport azure_c_shared_utility mbed-rtos mbed azure_uamqp_c wolfSSL
This sample showcases the usage of Azure IoT client libraries with the AMQP transport for sending/receiving raw messages from an IoT Hub.
Diff: iothub_client_sample_amqp.c
- Revision:
- 85:9809a1635421
- Parent:
- 81:e7cc4a10410d
--- a/iothub_client_sample_amqp.c Fri Dec 15 14:11:17 2017 -0800 +++ b/iothub_client_sample_amqp.c Wed Jan 17 08:59:10 2018 -0800 @@ -177,9 +177,16 @@ IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_LOG_TRACE, &traceOn); // Set keep alive is optional. If it is not set the default (240 secs) will be used. - uint32_t c2d_keep_alive_freq_secs = 120; - IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_C2D_KEEP_ALIVE_FREQ_SECS, &c2d_keep_alive_freq_secs); + uint32_t svc2cl_keep_alive_timeout_secs = 120; // service will send pings at 120 x 7/8 = 105 seconds. Higher the value, lesser the frequency of service side pings. + IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_SERVICE_SIDE_KEEP_ALIVE_FREQ_SECS, &svc2cl_keep_alive_timeout_secs); + // Set keep alive for remote idle is optional. If it is not set the default ratio of 1/2 will be used. For default value of 4 minutes, it will be 2 minutes (120 seconds) + double cl2svc_keep_alive_send_ratio = 7.0 / 8.0; // Set it to 210 seconds (240 x 7/8 = 210 seconds) for 4 minutes remote idle. Set it to 21 minutes for 25 minutes remote idle increased on per-hub basis via Support Request (SR) + if (IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_REMOTE_IDLE_TIMEOUT_RATIO, &cl2svc_keep_alive_send_ratio) != IOTHUB_CLIENT_OK) // client will send pings to service at 210 second interval for 4 minutes remote idle. For 25 minutes remote idle, it will be set to 21 minutes. + { + (void)printf("ERROR: IoTHubClient_remote_idle_timeout_ratio..........FAILED!\r\n"); + } + #ifdef SET_TRUSTED_CERT_IN_SAMPLES // For mbed add the certificate information if (IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_TRUSTED_CERT, certificates) != IOTHUB_CLIENT_OK)