COAP with amazon-freertos

Hello all,
Is it possible to integrate COAP protocol along with amazon-freertos and also can we send an message via COAP to a server using TCP and TLS connection instead of UDP.

I believe native CoAP requires UDP. If you scroll to the bottom of this page you will find a demo from 1nce that is using CoAP over cellular:

I tried using the native esp32 CoAP library with amazon-FreeRTOS but was getting this error while connecting to the AWS cloud.

You can’t use CoAP directly to AWS cloud, but the errors I see in your screenshot are TLS errors, not CoAP errors. Ittnot clear what you are trying to do.

Actually I want to run 2 protocols in the device not simultaneously but when called one at a time. I’m using CoAP to communicate to a private server and MQTT to communicate with AWS cloud. Only MQTT was working fine, but after adding the CoAP libraries even without calling the CoAP task, I’m getting this error and not able to establish the MQTT connection.

Your log seems to indicate a memory allocation failure preventing the TLS signing operations from happening. See if you can reduce your memory footprint during the TLS sign-on so that the memory allocations for the signing can take place. After the TLS connection is established, the memory will free up.

Defining a malloc failed hook might help

Thank you @jjulich and @rtel freeing up the memory worked and the device is able to create a TLS connection to AWS.
But sometimes the device keeps on reconnecting to the AWS by itself.

One of the functions of the MQTT Agent is to manage reconnections if the connection fails. You may be seeing the agent in action.