Getting an NSAPI_ERROR_DEVICE_ERROR when attempting to download a modestly sized AWS shadow using the mbed-client-for-aws


I’ve run into a strange error with the mbed AWS client when attempting to download a shadow. It works fine until the shadow gets to a certain size, somewhere around 200 - 300 characters. The client fails with an lwip NSAPI_ERROR_DEVICE_ERROR, which doesn’t make much sense, as we have a variety of firmware versions we have run on these board that do run against AWS and we have never seen any device errors or hardware issues.

I presume there is a buffer that needs to be increased somewhere, but I have changed all of the expected settings and am not seeing any different results.

We are using a board which is based on the MK64 and inherits from the K64F target. I’ve attached the code snippet, log output, and mbed_app.json to help. I’d love to know which setting needs to be changed to allow for larger AWS shadows.



    "config": {
        "aws-endpoint": {
            "help": "Endpoint URL",
            "value": "\"\""
        "main-stack-size": {
            "value": 16384
        "use-tls-socket": {
            "value": true
    "target_overrides": {
        "*": {
            "mbed-trace.enable": true,
            "mbed-trace.max-level": "TRACE_LEVEL_INFO",
            "platform.error-filename-capture-enabled": true,
            "platform.stdio-convert-newlines": true,
            "platform.stdio-baud-rate": 115200,
            "aws-client.shadow": true,
            "": true,
            "aws-client.shadow-get-response-max-size": 4096,
            "aws-client.buffer-size": 4096,
            "aws-client.shadow-update-document-max-size": 4096,


debug("Device Already Configured!\n");
        auto ret = client.downloadShadowDocument();
        if (ret == MBED_SUCCESS) {
            tr_info("Device Shadow document downloaded");
        } else {
            tr_error("AWSClient::downloadShadowDocument() failed: %d", ret);
            char* test_doc = "{\"state\":{}}";
            ret = client.updateShadowDocument(test_doc, strlen(test_doc));
            if( ret == MBED_SUCCESS){
                    tr_info("Device Shadow document created");
                tr_error("AWSClient::updateShadowDocument() failed: %d", ret);
                goto disconnect;


e[2Ke[39m[INFO][TLSW]: Closing TLSe[0m

e[2Ke[39m[INFO][TLSW]: Starting TLS handshake with redacted.amazonaws.come[0m

e[2Ke[39m[INFO][TLSW]: TLS connection to establishede[0m

e[2Ke[39m[INFO][TLSW]: Certificate verification passede[0m

e[2Ke[39m[INFO][AWS SDK]: Packet received. ReceivedBytes=2.e[0m

e[2Ke[39m[INFO][AWS SDK]: CONNACK session present bit not set.e[0m

e[2Ke[39m[INFO][AWS SDK]: Connection accepted.e[0m

e[2Ke[39m[INFO][AWS SDK]: Received MQTT CONNACK successfully from broker.e[0m

e[2Ke[39m[INFO][AWS SDK]: MQTT connection established with the broker.e[0m
Device Already Configured!

e[2Ke[39m[INFO][AWS SDK]: Packet received. ReceivedBytes=3.e[0m

e[2Ke[39m[INFO][AWS SDK]: Packet received. ReceivedBytes=3.e[0m

e[2Ke[31m[ERR ][TLSW]: mbedtls_ssl_read() failed: -0x7200 (-29184): SSL - An invalid SSL record was receivede[0m

e[2Ke[31m[ERR ][AWS SDK]: A single byte was not read from the transport: transportStatus=-3012.e[0m