Multiple HTTPS instances with mbedTLS on multithread/multitask system - ESP8266

Hi @roneld01

I did a test here and it seems that mbedtls_ssl_read is a blocking function. Is this correct?

I have this:

do
    {
        len = sizeof(buf) - 1;
        bzero(buf, sizeof(buf));
        ret = mbedtls_ssl_read(&ssl, (unsigned char *)buf, len);

        ESP_LOGI(TAG, "#### READ @@@@");

        if(ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE)
            continue;

        if(ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) 
        {
            //ESP_LOGI(TAG, "#### PEER CLOSE NOTIFY ####");
            ret = 0;
            break;
        }

        if(ret < 0)
        {
            //ESP_LOGE(TAG, "mbedtls_ssl_read returned -0x%x", -ret);
            break;
        }

        if(ret == 0)
        {
            //ESP_LOGI(TAG, "connection closed");
            break;
        }

        len = ret;
        //ESP_LOGD(TAG, "%d bytes read", len);

        /* Print response directly to stdout as it is read */
        for(int i = 0; i < len; i++) 
        {
            putchar(buf[i]);
        }

    } while(1);

And the string is being printed only when I receive the keep-alive message from FIrebase each 30 seconds.