Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp iothub_client_sample_amqp ... more
Revision 37:abd16824f63b, committed 2017-06-30
- Comitter:
- AzureIoTClient
- Date:
- Fri Jun 30 10:40:33 2017 -0700
- Parent:
- 36:f78f9a56869e
- Child:
- 38:6435c6e3d55c
- Commit message:
- 1.1.18
Changed in this revision
--- a/iothubtransport_amqp_common.c Fri Jun 16 16:12:09 2017 -0700
+++ b/iothubtransport_amqp_common.c Fri Jun 30 10:40:33 2017 -0700
@@ -46,6 +46,7 @@
#define DEFAULT_SAS_TOKEN_LIFETIME_SECS 3600
#define DEFAULT_SAS_TOKEN_REFRESH_TIME_SECS 1800
#define MAX_NUMBER_OF_DEVICE_FAILURES 5
+#define DEFAULT_C2D_KEEP_ALIVE_FREQ_SECS 240
#define DEFAULT_RETRY_POLICY IOTHUB_CLIENT_RETRY_EXPONENTIAL_BACKOFF_WITH_JITTER
// DEFAULT_MAX_RETRY_TIME_IN_SECS = 0 means infinite retry.
#define DEFAULT_MAX_RETRY_TIME_IN_SECS 0
@@ -84,6 +85,7 @@
OPTIONHANDLER_HANDLE saved_tls_options; // Here are the options from the xio layer if any is saved.
AMQP_TRANSPORT_STATE state; // Current state of the transport.
RETRY_CONTROL_HANDLE connection_retry_control; // Controls when the re-connection attempt should occur.
+ size_t c2d_keep_alive_freq_secs; // Service to device keep alive frequency
char* http_proxy_hostname;
int http_proxy_port;
@@ -665,6 +667,8 @@
amqp_connection_config.is_trace_on = transport_instance->is_trace_on;
amqp_connection_config.on_state_changed_callback = on_amqp_connection_state_changed;
amqp_connection_config.on_state_changed_context = transport_instance;
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_12_003: [AMQP connection will be configured using the `c2d_keep_alive_freq_secs` value from SetOption ]
+ amqp_connection_config.c2d_keep_alive_freq_secs = transport_instance->c2d_keep_alive_freq_secs;
// Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_027: [If `transport->preferred_authentication_method` is CBS, AMQP_CONNECTION_CONFIG shall be set with `create_sasl_io` = true and `create_cbs_connection` = true]
if (transport_instance->preferred_authentication_mode == AMQP_TRANSPORT_AUTHENTICATION_MODE_CBS)
@@ -1314,6 +1318,8 @@
instance->option_sas_token_refresh_time_secs = DEFAULT_SAS_TOKEN_REFRESH_TIME_SECS;
instance->option_cbs_request_timeout_secs = DEFAULT_CBS_REQUEST_TIMEOUT_SECS;
instance->option_send_event_timeout_secs = DEFAULT_EVENT_SEND_TIMEOUT_SECS;
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_12_002: [The connection idle timeout parameter default value shall be set to 240000 milliseconds using connection_set_idle_timeout()]
+ instance->c2d_keep_alive_freq_secs = DEFAULT_C2D_KEEP_ALIVE_FREQ_SECS;
// Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_012: [If IoTHubTransport_AMQP_Common_Create succeeds it shall return a pointer to `instance`.]
result = (TRANSPORT_LL_HANDLE)instance;
@@ -1377,6 +1383,7 @@
// there is not a preferred authentication mode set yet on the transport.
// Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_019: [If `instance->amqp_connection` is NULL, it shall be established]
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_12_003: [AMQP connection will be configured using the `c2d_keep_alive_freq_secs` value from SetOption ]
if (transport_instance->amqp_connection == NULL && establish_amqp_connection(transport_instance) != RESULT_OK)
{
LogError("AMQP transport failed to establish connection with service.");
@@ -1669,6 +1676,11 @@
is_device_specific_option = true;
transport_instance->option_send_event_timeout_secs = *(size_t*)value;
}
+ else if (strcmp(OPTION_C2D_KEEP_ALIVE_FREQ_SECS, option) == 0)
+ {
+ is_device_specific_option = false;
+ transport_instance->c2d_keep_alive_freq_secs = *(size_t*)value;
+ }
else
{
is_device_specific_option = false;
--- a/iothubtransport_amqp_connection.c Fri Jun 16 16:12:09 2017 -0700
+++ b/iothubtransport_amqp_connection.c Fri Jun 30 10:40:33 2017 -0700
@@ -14,7 +14,6 @@
#include "azure_uamqp_c/connection.h"
#define RESULT_OK 0
-#define DEFAULT_CONNECTION_IDLE_TIMEOUT 240000
#define DEFAULT_INCOMING_WINDOW_SIZE UINT_MAX
#define DEFAULT_OUTGOING_WINDOW_SIZE 100
#define SASL_IO_OPTION_LOG_TRACE "logtrace"
@@ -33,6 +32,7 @@
AMQP_CONNECTION_STATE current_state;
ON_AMQP_CONNECTION_STATE_CHANGED on_state_changed_callback;
const void* on_state_changed_context;
+ uint32_t c2d_keep_alive_freq_secs;
} AMQP_CONNECTION_INSTANCE;
@@ -195,8 +195,7 @@
result = __FAILURE__;
LogError("Failed creating the AMQP connection (connection_create2 failed)");
}
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_CONNECTION_09_073: [The connection idle timeout parameter shall be set to 240000 milliseconds using connection_set_idle_timeout()]
- else if (connection_set_idle_timeout(instance->connection_handle, DEFAULT_CONNECTION_IDLE_TIMEOUT) != RESULT_OK)
+ else if (connection_set_idle_timeout(instance->connection_handle, 1000 * instance->c2d_keep_alive_freq_secs) != RESULT_OK)
{
// Codes_SRS_IOTHUBTRANSPORT_AMQP_CONNECTION_09_074: [If connection_set_idle_timeout() fails, amqp_connection_create() shall fail and return NULL]
result = __FAILURE__;
@@ -382,6 +381,8 @@
// Codes_SRS_IOTHUBTRANSPORT_AMQP_CONNECTION_09_061: [`config->on_state_changed_context` shall be saved on `instance->on_state_changed_context`]
instance->on_state_changed_context = config->on_state_changed_context;
+ instance->c2d_keep_alive_freq_secs = (uint32_t)config->c2d_keep_alive_freq_secs;
+
instance->current_state = AMQP_CONNECTION_STATE_CLOSED;
// Codes_SRS_IOTHUBTRANSPORT_AMQP_CONNECTION_09_011: [If `config->create_sasl_io` is true or `config->create_cbs_connection` is true, amqp_connection_create() shall create SASL I/O]
--- a/iothubtransport_amqp_connection.h Fri Jun 16 16:12:09 2017 -0700 +++ b/iothubtransport_amqp_connection.h Fri Jun 30 10:40:33 2017 -0700 @@ -34,6 +34,7 @@ ON_AMQP_CONNECTION_STATE_CHANGED on_state_changed_callback; const void* on_state_changed_context; + size_t c2d_keep_alive_freq_secs; } AMQP_CONNECTION_CONFIG; typedef struct AMQP_CONNECTION_INSTANCE* AMQP_CONNECTION_HANDLE;
