Azure / azure-iot-middleware-freertos

Azure IoT Middleware for FreeRTOS
https://azure.github.io/azure-iot-middleware-freertos/
MIT License
79 stars 25 forks source link

Hidden network error on AzureIoTHTTP_RequestSize #315

Open gfurtadoalmeida opened 1 year ago

gfurtadoalmeida commented 1 year ago

Is there an existing issue for this?

Version

1.1.0

Description of the issue

Context

The AzureIoTHTTP_RequestSize function is used to get a resource size before downloading it. Its return value is the resource size or -1 on error.

Issue

When a network error occurs, especially the HTTPStatus::HTTPNoResponse one, there is no way to know and take a remediating action, like retrying the call.

Suggestions

A) Change the function contract to return a HTTPStatus and add an out parameter to return the resource size.
Downside: breaking change.

HTTPStatus_t AzureIoTHTTP_RequestSize( AzureIoTHTTPHandle_t xHTTPHandle,
                                       char * pucDataBuffer,
                                       uint32_t ulDataBufferLength,
                                       int32_t *lSize )

B) Add a int32_t lLastError field on the AzureIoTHTTPHandle_t structure and create an AzureIoTHTTP_GetLastError function. Downside: 4 bytes and instrumenting all functions to set the error field with the last error received.

HTTPStatus_t AzureIoTHTTP_GetLastError( AzureIoTHTTPHandle_t xHTTPHandle )

Expected behavior

Know what error occurred with the AzureIoTHTTP_RequestSize function.

Steps to reproduce the issue

No response

Relevant log output

E (31646) AZ_SDK: Response not received: Zero returned from transport recv: totalReceived=0

Code of Conduct