tonyp7 / esp32-wifi-manager

Captive Portal for ESP32 that can connect to a saved wireless network or start an access point where you can connect to existing wifis.
MIT License
664 stars 217 forks source link

Wifi Manager static IP and DNS configuration #31

Closed zafersn closed 5 years ago

zafersn commented 5 years ago

Hi. I'm trying to connect to aws_iot, but I get "aws_iot: failed! mbedtls_net_connect returned -0x52" error. This error may be a network connection problem. The point I'm curious about is how the network configuration of the aws configuration is trying to connect and how I can select it. I'm using aws embedded c sdk.

and

I call aws_set_event_start() in the following code block.

        uxBits = xEventGroupWaitBits(wifi_manager_event_group, WIFI_MANAGER_WIFI_CONNECTED_BIT | WIFI_MANAGER_STA_DISCONNECT_BIT, pdFALSE, pdFALSE, portMAX_DELAY );

            if(uxBits & (WIFI_MANAGER_WIFI_CONNECTED_BIT | WIFI_MANAGER_STA_DISCONNECT_BIT)){

                /* Update the json regardless of connection status.
                 * If connection was succesful an IP will get assigned.
                 * If the connection attempt is failed we mark it as a failed connection attempt
                 * as it is important for the front end app to distinguish failed attempt to
                 * regular disconnects
                 */
                if(wifi_manager_lock_json_buffer( portMAX_DELAY )){

                    /* only save the config if the connection was successful! */
                    if(uxBits & WIFI_MANAGER_WIFI_CONNECTED_BIT){

                        /* generate the connection info with success */
                        wifi_manager_generate_ip_info_json( UPDATE_CONNECTION_OK );

                        /* save wifi config in NVS */
                        wifi_manager_save_sta_config();
                        #if WIFI_MANAGER_DEBUG
                                    printf("aws_start_Bit\n");
                        #endif
                        aws_set_event_start();
                    }
                    else{

                        /* failed attempt to connect regardles of the reason */
                        wifi_manager_generate_ip_info_json( UPDATE_FAILED_ATTEMPT );

                        /* otherwise: reset the config */
                        memset(wifi_manager_config_sta, 0x00, sizeof(wifi_config_t));
                    }
                    wifi_manager_unlock_json_buffer();
                }
                else{
                    /* Even if someone were to furiously refresh a web resource that needs the json mutex,
                     * it seems impossible that this thread cannot obtain the mutex. Abort here is reasonnable.
                     */
                    abort();
                }
            }

subscribe_publish_sample.c


/*
 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
/**
 * @file subscribe_publish_sample.c
 * @brief simple MQTT publish and subscribe on the same topic
 *
 * This example takes the parameters from the build configuration and establishes a connection to the AWS IoT MQTT Platform.
 * It subscribes and publishes to the same topic - "test_topic/esp32"
 *
 * Some setup is required. See example README for details.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>

#include "aws_iot_config.h"
#include "aws_iot_log.h"
#include "aws_iot_version.h"
#include "aws_iot_mqtt_client_interface.h"
#include "subscribe_publish_aws.h"
#include "lufft_connect.h"
#include "wifi_manager.h"

/*****************************************************************************/
/*                           GLOBALS                                         */
/*****************************************************************************/

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/

#define TOPIC "test_topic/esp32"
#define TOPIC_LEN  strlen(TOPIC)

#if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)

extern const uint8_t aws_root_ca_pem_start[] asm("_binary_aws_root_ca_pem_start");
extern const uint8_t aws_root_ca_pem_end[] asm("_binary_aws_root_ca_pem_end");
extern const uint8_t certificate_pem_crt_start[] asm("_binary_certificate_pem_crt_start");
extern const uint8_t certificate_pem_crt_end[] asm("_binary_certificate_pem_crt_end");
extern const uint8_t private_pem_key_start[] asm("_binary_private_pem_key_start");
extern const uint8_t private_pem_key_end[] asm("_binary_private_pem_key_end");

#elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)

static const char * DEVICE_CERTIFICATE_PATH = CONFIG_EXAMPLE_CERTIFICATE_PATH;
static const char * DEVICE_PRIVATE_KEY_PATH = CONFIG_EXAMPLE_PRIVATE_KEY_PATH;
static const char * ROOT_CA_PATH = CONFIG_EXAMPLE_ROOT_CA_PATH;

#else
#error "Invalid method for loading certs"
#endif

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

EventGroupHandle_t aws_connect_event_group;

/**
 * @brief Default MQTT HOST URL is pulled from the aws_iot_config.h
 */
char HostAddress[255] = AWS_IOT_MQTT_HOST;

/**
 * @brief Default MQTT port is pulled from the aws_iot_config.h
 */
uint32_t port = AWS_IOT_MQTT_PORT;

AWS_IoT_Client client;

//const int CONNECTED_BIT = BIT0;

bool aws_connect_success_Flag = false;

static const char *TAG = "subpub";

/*****************************************************************************/
/*                           FUNCTIONS                                       */
/*****************************************************************************/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

void iot_subscribe_callback_handler(AWS_IoT_Client *pClient, char *topicName, uint16_t topicNameLen,
                                    IoT_Publish_Message_Params *params, void *pData) {
#if WIFI_MANAGER_DEBUG
    //ESP_LOGI(TAG, "Subscribe callback");
    //ESP_LOGI(TAG, "%.*s\t%.*s", topicNameLen, topicName, (int) params->payloadLen, (char *)params->payload);
    printf("Subscribe callback");
    printf("%.*s\t%.*s", topicNameLen, topicName, (int) params->payloadLen, (char *)params->payload);
#endif
}

void disconnectCallbackHandler(AWS_IoT_Client *pClient, void *data) {
#if WIFI_MANAGER_DEBUG
    //ESP_LOGW(TAG, "MQTT Disconnect");
    printf("MQTT Disconnect");
#endif
    IoT_Error_t rc = FAILURE;

    if(NULL == pClient) {
        return;
    }

    if(aws_iot_is_autoreconnect_enabled(pClient)) {
#if WIFI_MANAGER_DEBUG
        ////ESP_LOGI(TAG, "Auto Reconnect is enabled, Reconnecting attempt will start now");
        printf("Auto Reconnect is enabled, Reconnecting attempt will start now");
#endif
    } else {
#if WIFI_MANAGER_DEBUG
        ////ESP_LOGW(TAG, "Auto Reconnect not enabled. Starting manual reconnect...");
        printf("Auto Reconnect not enabled. Starting manual reconnect...");
#endif
        rc = aws_iot_mqtt_attempt_reconnect(pClient);
        if(NETWORK_RECONNECTED == rc) {
#if WIFI_MANAGER_DEBUG
            ////ESP_LOGW(TAG, "Manual Reconnect Successful");
            printf("Manual Reconnect Successful");
#endif
        } else {
#if WIFI_MANAGER_DEBUG
            ////ESP_LOGW(TAG, "Manual Reconnect Failed - %d", rc);
            printf("Manual Reconnect Failed - %d", rc);
#endif
        }
    }
}

void aws_iot_publish_message(IoT_Publish_Message_Params paramsQOS1)
{

    IoT_Error_t rc = FAILURE;
#if WIFI_MANAGER_DEBUG
    ////ESP_LOGI(TAG, "mess: %s",(char*)paramsQOS1.payload);
    printf("mess: %s",(char*)paramsQOS1.payload);
#endif
    rc = aws_iot_mqtt_publish(&client, TOPIC, TOPIC_LEN, &paramsQOS1);
    if (rc == MQTT_REQUEST_TIMEOUT_ERROR) {
#if WIFI_MANAGER_DEBUG
        ////ESP_LOGW(TAG, "QOS1 publish ack not received.");
        printf("QOS1 publish ack not received.");
#endif
        //rc = SUCCESS;
    }

}

void aws_set_event_start()
{
    xEventGroupSetBits(aws_connect_event_group, AWS_CONNECT_START_BIT_0 );
}

void aws_iot_task(void *param)
{

            IoT_Error_t rc = FAILURE;

            aws_connect_event_group= xEventGroupCreate();

            IoT_Client_Init_Params mqttInitParams = iotClientInitParamsDefault;
            IoT_Client_Connect_Params connectParams = iotClientConnectParamsDefault;

          //  IoT_Publish_Message_Params paramsQOS0;

#if WIFI_MANAGER_DEBUG
            //ESP_LOGI(TAG, "AWS IoT SDK Version %d.%d.%d-%s", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG);
            printf( "AWS IoT SDK Version %d.%d.%d-%s\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG);
#endif
            mqttInitParams.enableAutoReconnect = false; // We enable this later below
            mqttInitParams.pHostURL = HostAddress;
            mqttInitParams.port = port;

        #if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)
            mqttInitParams.pRootCALocation = (const char *)aws_root_ca_pem_start;
            mqttInitParams.pDeviceCertLocation = (const char *)certificate_pem_crt_start;
            mqttInitParams.pDevicePrivateKeyLocation = (const char *)private_pem_key_start;

        #elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)
            mqttInitParams.pRootCALocation = ROOT_CA_PATH;
            mqttInitParams.pDeviceCertLocation = DEVICE_CERTIFICATE_PATH;
            mqttInitParams.pDevicePrivateKeyLocation = DEVICE_PRIVATE_KEY_PATH;
        #endif

            mqttInitParams.mqttCommandTimeout_ms = 20000;
            mqttInitParams.tlsHandshakeTimeout_ms = 5000;
            mqttInitParams.isSSLHostnameVerify = true;
            mqttInitParams.disconnectHandler = disconnectCallbackHandler;
            mqttInitParams.disconnectHandlerData = NULL;

        #ifdef CONFIG_EXAMPLE_SDCARD_CERTS
#if WIFI_MANAGER_DEBUG
            //ESP_LOGI(TAG, "Mounting SD card...");
            printf("Mounting SD card...");
#endif
            sdmmc_host_t host = SDMMC_HOST_DEFAULT();
            sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
            esp_vfs_fat_sdmmc_mount_config_t mount_config = {
                .format_if_mount_failed = false,
                .max_files = 3,
            };
            sdmmc_card_t* card;
            esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
            if (ret != ESP_OK) {
#if WIFI_MANAGER_DEBUG
                //ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret));
                printf("Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret));
#endif
                abort();
            }
        #endif
#if WIFI_MANAGER_DEBUG
            //ESP_LOGI(TAG, "AWS init ...");
            printf("AWS init ...\n");
#endif
            rc = aws_iot_mqtt_init(&client, &mqttInitParams);
            if(SUCCESS != rc) {
#if WIFI_MANAGER_DEBUG
                //ESP_LOGE(TAG, "aws_iot_mqtt_init returned error : %d ", rc);
                printf("aws_iot_mqtt_init returned error : %d ", rc);
#endif
                abort();
            }
#if WIFI_MANAGER_DEBUG
            //ESP_LOGI(TAG, "AWS init ...");
    //      printf("AWS init 22 ...\n");
#endif

            #if WIFI_MANAGER_DEBUG
                        //ESP_LOGI(TAG, "AWS init ...");
            //          printf("AWS init 333 ...\n");
            #endif
            /* Wait for WiFI to show as connected */
            xEventGroupWaitBits(aws_connect_event_group, AWS_CONNECT_START_BIT_0,
                                                            false, true, portMAX_DELAY);
            #if WIFI_MANAGER_DEBUG
                        //ESP_LOGI(TAG, "AWS init ...");
                //      printf("AWS init 44 ...\n");
            #endif
            connectParams.keepAliveIntervalInSec = 10;
            connectParams.isCleanSession = true;
            connectParams.MQTTVersion = MQTT_3_1_1;
            /* Client ID is set in the menuconfig of the example */
            connectParams.pClientID = CONFIG_AWS_EXAMPLE_CLIENT_ID;
            connectParams.clientIDLen = (uint16_t) strlen(CONFIG_AWS_EXAMPLE_CLIENT_ID);
            connectParams.isWillMsgPresent = false;
#if WIFI_MANAGER_DEBUG
            //ESP_LOGI(TAG, "Connecting to AWS...");
            printf("Connecting to AWS...");
#endif
            do {
                rc = aws_iot_mqtt_connect(&client, &connectParams);
                if(SUCCESS != rc) {
#if WIFI_MANAGER_DEBUG
                    //ESP_LOGE(TAG, "Error(%d) connecting to %s:%d", rc, mqttInitParams.pHostURL, mqttInitParams.port);
                    printf("Error(%d) connecting to %s:%d", rc, mqttInitParams.pHostURL, mqttInitParams.port);
#endif
                 //   vTaskDelay(1000 / portTICK_RATE_MS);
                }
            } while(SUCCESS != rc);

            /*
             * Enable Auto Reconnect functionality. Minimum and Maximum time of Exponential backoff are set in aws_iot_config.h
             *  #AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL
             *  #AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL
             */
#if WIFI_MANAGER_DEBUG
                //ESP_LOGI(TAG, "autoreconnect...");
                printf("autoreconnect...");
#endif
            rc = aws_iot_mqtt_autoreconnect_set_status(&client, true);
            if(SUCCESS != rc) {
#if WIFI_MANAGER_DEBUG
                //ESP_LOGE(TAG, "Unable to set Auto Reconnect to true - %d", rc);
                printf("Unable to set Auto Reconnect to true - %d", rc);
#endif
                abort();
            }

#if WIFI_MANAGER_DEBUG
            //ESP_LOGI(TAG, "Subscribing...");
            printf("Subscribing...");
#endif
            rc = aws_iot_mqtt_subscribe(&client, TOPIC, TOPIC_LEN, QOS0, iot_subscribe_callback_handler, NULL);
            if(SUCCESS != rc) {
#if WIFI_MANAGER_DEBUG
                //ESP_LOGE(TAG, "Error subscribing : %d ", rc);
                printf("Error subscribing : %d ", rc);
#endif
                abort();
            }
#if WIFI_MANAGER_DEBUG
            //ESP_LOGI(TAG, "Subscribing Success.");
            printf("Subscribing Success.");
#endif

            if(SUCCESS == rc)
            {
                aws_connect_success_Flag=true;
            }
            while((NETWORK_ATTEMPTING_RECONNECT == rc || NETWORK_RECONNECTED == rc || SUCCESS == rc)) {

                //Max time the yield function will wait for read messages
                rc = aws_iot_mqtt_yield(&client, 100);
                if(NETWORK_ATTEMPTING_RECONNECT == rc) {
                    // If the client is attempting to reconnect we will skip the rest of the loop.
                    aws_connect_success_Flag=false;
                    continue;
                }
                if(SUCCESS == rc)
                {
                    aws_connect_success_Flag=true;
                }
                tcp_clien_connect_lufft();
             //   //ESP_LOGI(TAG, "Stack remaining for task '%s' is %d bytes", pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL));

            }

            aws_iot_abort();

}
//void aws_iot_task(void *param) {
//    char cPayload[100];
//
//    int32_t i = 0;
//
//    IoT_Error_t rc = FAILURE;
//
//    AWS_IoT_Client client;
//    IoT_Client_Init_Params mqttInitParams = iotClientInitParamsDefault;
//    IoT_Client_Connect_Params connectParams = iotClientConnectParamsDefault;
//
//    IoT_Publish_Message_Params paramsQOS0;
//    IoT_Publish_Message_Params paramsQOS1;
//
//    ESP_LOGI(TAG, "AWS IoT SDK Version %d.%d.%d-%s", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_TAG);
//
//    mqttInitParams.enableAutoReconnect = false; // We enable this later below
//    mqttInitParams.pHostURL = HostAddress;
//    mqttInitParams.port = port;
//
//#if defined(CONFIG_EXAMPLE_EMBEDDED_CERTS)
//    mqttInitParams.pRootCALocation = (const char *)aws_root_ca_pem_start;
//    mqttInitParams.pDeviceCertLocation = (const char *)certificate_pem_crt_start;
//    mqttInitParams.pDevicePrivateKeyLocation = (const char *)private_pem_key_start;
//
//#elif defined(CONFIG_EXAMPLE_FILESYSTEM_CERTS)
//    mqttInitParams.pRootCALocation = ROOT_CA_PATH;
//    mqttInitParams.pDeviceCertLocation = DEVICE_CERTIFICATE_PATH;
//    mqttInitParams.pDevicePrivateKeyLocation = DEVICE_PRIVATE_KEY_PATH;
//#endif
//
//    mqttInitParams.mqttCommandTimeout_ms = 20000;
//    mqttInitParams.tlsHandshakeTimeout_ms = 5000;
//    mqttInitParams.isSSLHostnameVerify = true;
//    mqttInitParams.disconnectHandler = disconnectCallbackHandler;
//    mqttInitParams.disconnectHandlerData = NULL;
//
//#ifdef CONFIG_EXAMPLE_SDCARD_CERTS
//    ESP_LOGI(TAG, "Mounting SD card...");
//    sdmmc_host_t host = SDMMC_HOST_DEFAULT();
//    sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
//    esp_vfs_fat_sdmmc_mount_config_t mount_config = {
//        .format_if_mount_failed = false,
//        .max_files = 3,
//    };
//    sdmmc_card_t* card;
//    esp_err_t ret = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
//    if (ret != ESP_OK) {
//        ESP_LOGE(TAG, "Failed to mount SD card VFAT filesystem. Error: %s", esp_err_to_name(ret));
//        abort();
//    }
//#endif
//
//    rc = aws_iot_mqtt_init(&client, &mqttInitParams);
//    if(SUCCESS != rc) {
//        ESP_LOGE(TAG, "aws_iot_mqtt_init returned error : %d ", rc);
//        abort();
//    }
//
//    /* Wait for WiFI to show as connected */
//    xEventGroupWaitBits(aws_connect_event_group, AWS_CONNECT_START_BIT_0,
//                        false, true, portMAX_DELAY);
//
//    connectParams.keepAliveIntervalInSec = 10;
//    connectParams.isCleanSession = true;
//    connectParams.MQTTVersion = MQTT_3_1_1;
//    /* Client ID is set in the menuconfig of the example */
//    connectParams.pClientID = CONFIG_AWS_EXAMPLE_CLIENT_ID;
//    connectParams.clientIDLen = (uint16_t) strlen(CONFIG_AWS_EXAMPLE_CLIENT_ID);
//    connectParams.isWillMsgPresent = false;
//
//    ESP_LOGI(TAG, "Connecting to AWS...");
//    do {
//        rc = aws_iot_mqtt_connect(&client, &connectParams);
//        if(SUCCESS != rc) {
//            ESP_LOGE(TAG, "Error(%d) connecting to %s:%d", rc, mqttInitParams.pHostURL, mqttInitParams.port);
//            vTaskDelay(1000 / portTICK_RATE_MS);
//        }
//    } while(SUCCESS != rc);
//
//    /*
//     * Enable Auto Reconnect functionality. Minimum and Maximum time of Exponential backoff are set in aws_iot_config.h
//     *  #AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL
//     *  #AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL
//     */
//    rc = aws_iot_mqtt_autoreconnect_set_status(&client, true);
//    if(SUCCESS != rc) {
//        ESP_LOGE(TAG, "Unable to set Auto Reconnect to true - %d", rc);
//        abort();
//    }
//
//    ESP_LOGI(TAG, "Subscribing...");
//    rc = aws_iot_mqtt_subscribe(&client, TOPIC, TOPIC_LEN, QOS0, iot_subscribe_callback_handler, NULL);
//    if(SUCCESS != rc) {
//        ESP_LOGE(TAG, "Error subscribing : %d ", rc);
//        abort();
//    }
//
//    sprintf(cPayload, "%s : %d ", "hello from SDK", i);
//
//    paramsQOS0.qos = QOS0;
//    paramsQOS0.payload = (void *) cPayload;
//    paramsQOS0.isRetained = 0;
//
//    paramsQOS1.qos = QOS1;
//    paramsQOS1.payload = (void *) cPayload;
//    paramsQOS1.isRetained = 0;
//
//    while((NETWORK_ATTEMPTING_RECONNECT == rc || NETWORK_RECONNECTED == rc || SUCCESS == rc)) {
//
//        //Max time the yield function will wait for read messages
//        rc = aws_iot_mqtt_yield(&client, 100);
//        if(NETWORK_ATTEMPTING_RECONNECT == rc) {
//            // If the client is attempting to reconnect we will skip the rest of the loop.
//            continue;
//        }
//
//        ESP_LOGI(TAG, "Stack remaining for task '%s' is %d bytes", pcTaskGetTaskName(NULL), uxTaskGetStackHighWaterMark(NULL));
//        vTaskDelay(1000 / portTICK_RATE_MS);
//        sprintf(cPayload, "%s : %d ", "hello from ESP32 (QOS0)", i++);
//        paramsQOS0.payloadLen = strlen(cPayload);
//        rc = aws_iot_mqtt_publish(&client, TOPIC, TOPIC_LEN, &paramsQOS0);
//
//        sprintf(cPayload, "%s : %d ", "hello from ESP32 (QOS1)", i++);
//        paramsQOS1.payloadLen = strlen(cPayload);
//        rc = aws_iot_mqtt_publish(&client, TOPIC, TOPIC_LEN, &paramsQOS1);
//        if (rc == MQTT_REQUEST_TIMEOUT_ERROR) {
//            ESP_LOGW(TAG, "QOS1 publish ack not received.");
//            rc = SUCCESS;
//        }
//    }
//
//    ESP_LOGE(TAG, "An error occurred in the main loop.");
//    abort();
//}

void aws_iot_abort(void)
{
#if WIFI_MANAGER_DEBUG
     //ESP_LOGE(TAG, "An error occurred in the main loop.");
     printf("An error occurred in the main loop.");
#endif
     abort();
}

/*****************************************************************************/
/* END OF FILE */
/*****************************************************************************/
tonyp7 commented 5 years ago

This does not seem to be a valid issue for the wifi manager

zafersn commented 5 years ago

Hi @tonyp7 . I think it is about wifi manager. Because.

I've read and applied a solution for the "mbedtls_net_connect returned -0x52" error. https://stackoverflow.com/a/46749602

It is said that the problem may be the static IP configuration and the missing or incorrect setting of the DNS settings. When I examined the wifimanager configuration, I observed that there was a static IP configuration available.

I have no knowledge about network configuration, so I tried to switch off and try static ip configurations in wifi configuration settings in wifimanager.c and the result was successful. I am no longer receiving the error "aws_iot: failed! Mbedtls_net_connect returned -0x52" . But now after receiving the message "autoreconnect ... Subscribing ... Subscribing Success", I get an error like "MQTT DisconnectAuto Reconnect is Enabled," when I wait before publishing a message. If I want to post a message, I get an error such as "E (58050) aws_iot: failed! Mbedtls_ssl_write returned -0x50".