- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all:
I am trying to reconnect after MQTT disconnected.After several times successful reconnection and I can't reconnect any more. So I print the "_eheap-sbrk_heap_top " to check to RAM size I left everytime I make reconnection . I found it will reduce about 8-12K ram every time I reconnect success. So that may expand how my situation appear . I think it should be the problem of “Recycling resources” part .I hope the team can explain that.
here is my mqtt connect function.
/*
* Open a connection and wait for MQTT_REQUEST_TIMEOUT period to receive a connection open OK event
*/
wiced_result_t aws_mqtt_conn_open( wiced_mqtt_object_t mqtt_obj, wiced_mqtt_callback_t callback )
{
wiced_result_t ret = WICED_SUCCESS;
wiced_interface_t interface = WICED_STA_INTERFACE;
do {
wiced_hostname_lookup( aws_app_info->region, &broker_address, 10000 );
wiced_rtos_delay_milliseconds( 100 );
}
while(GET_IPV4_ADDRESS(broker_address)==0);
WPRINT_APP_INFO(("[MQTT] Connecting to broker %u.%u.%u.%u ...\n\n", (uint8_t)(GET_IPV4_ADDRESS(broker_address) >> 24),
(uint8_t)(GET_IPV4_ADDRESS(broker_address) >> 16),
(uint8_t)(GET_IPV4_ADDRESS(broker_address) >> 8),
(uint8_t)(GET_IPV4_ADDRESS(broker_address) >> 0)));
wiced_mqtt_init( aws_app_info->mqtt_object );
WPRINT_APP_INFO(("[MQTT] Connecting to MQTT Broker...\n"));
ret = wiced_mqtt_connect( mqtt_obj, &broker_address, interface, callback, &security, &conninfo );
if ( ret != WICED_SUCCESS )
{
WPRINT_APP_ERROR(("[MQTT] Failed to connect MQTT Broker\n"));
ret = WICED_ERROR;
goto _AWS_MQTT_CONN_OPEN_END;
}
if ( mqtt_wait_for( WICED_MQTT_EVENT_TYPE_CONNECT_REQ_STATUS, MQTT_REQUEST_TIMEOUT ) != WICED_SUCCESS )
{
WPRINT_APP_ERROR(("[MQTT] Failed to connect MQTT Broker\n"));
ret = WICED_ERROR;
goto _AWS_MQTT_CONN_OPEN_END;
}
WPRINT_APP_INFO(("[MQTT] Successfully connected MQTT Broker\n"));
_AWS_MQTT_CONN_OPEN_END:
return ret;
}
do
{
ret = aws_mqtt_conn_open( app_info.mqtt_object, mqtt_connection_event_cb );
connection_retries++ ;
host_rtos_delay_milliseconds( 1000 );
} while ( ( ret != WICED_SUCCESS ) && ( connection_retries < WICED_MQTT_CONNECTION_NUMBER_OF_RETRIES ) );
- Labels:
-
AWS
-
Web Services