Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for espressif#3460 issue #4424

Merged
merged 3 commits into from
Nov 2, 2020
Merged

Fix for espressif#3460 issue #4424

merged 3 commits into from
Nov 2, 2020

Conversation

igolubic
Copy link
Contributor

@igolubic igolubic commented Oct 18, 2020

Fixes: #3460

This code has been run in production for 1 month and it looks stable, no data dropped and it definitely fixes the issue described. I think that this can be merged to avoid using custom package referencing in PlatformIO that has been used in quite a few projects for now.

@igolubic igolubic changed the title Fix for https://github.com/espressif/arduino-esp32/issues/3460 issue Fix for espressif#3460 issue Oct 18, 2020
@Bmooij
Copy link
Contributor

Bmooij commented Oct 19, 2020

It seems logic to remove the while statement to prevent infinite looping.
I will test this solution the coming days

@me-no-dev me-no-dev merged commit d6b9187 into espressif:master Nov 2, 2020
@bhupiister
Copy link

@igolubic If found this as more suitable, as it may take multiple attempts before it gets successful.. i have locked trials to 100

int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, size_t len)
{
    log_v("Writing HTTP request with %d bytes...", len); // for low level debug
    int ret = -1;
    int retry = 0;
    while ((ret = mbedtls_ssl_write(&ssl_client->ssl_ctx, data, len)) <= 0)
    {
        if ((ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret < 0) || retry >= 100)
        {
            log_v("Trial #  %d", retry);     // for low level debug // Show number of attempts taken 
            log_v("Handling error %d", ret); // for low level debug
            return handle_error(ret);
        }
        retry++;
        // wait for space to become available
        vTaskDelay(2);
    }
    log_v("Trial #  %d", retry); // for low level debug // Show number of attempts taken 
    return ret;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WifiClientSecure hangs on write - socket error
4 participants