Skip to content

Device connects to AWS IoT but disconnects immediately using coreMQTT-Agent (IDFGH-16598) (CA-366) #250

@gajananmaske1234

Description

@gajananmaske1234

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

windows 10 , V 5 . 3 2

Espressif SoC revision.

ESP32 WROOM 32 UE

Operating System used.

Windows

How did you build your project?

Command line with CMake

If you are using Windows, please specify command line type.

None

Development Kit.

NA

Power Supply used.

USB

What is the expected behavior?

It should continuously connect if device alive.

What is the actual behavior?

Hi team,

I'm using the coreMQTT-Agent library to connect my embedded device to AWS IoT Core. The device successfully establishes a TLS and MQTT connection, but it disconnects almost immediately after connecting. This cycle repeats continuously — connect, then disconnect.

Here’s what I’ve confirmed so far:

TLS handshake completes successfully

MQTT connection is acknowledged by AWS

I'm using valid device certificates and root CA

The client ID is unique

Keep-alive is set to 120 seconds

MQTT topics are allowed in the attached AWS IoT policy

Questions:

Is this behavior expected with coreMQTT-Agent?

Should the connection remain persistent unless explicitly closed?

Are there known causes for immediate disconnects after successful connection?

Any guidance or troubleshooting tips would be appreciated!

Thanks in advance.

Steps to reproduce.

NA
...

Debug Logs.

E (25493) network_transport: Connection closed
E (25493) coreMQTT: Call to receiveSingleIteration failed. Status=MQTTRecvFailed
I (25493) sub_pub_unsub_demo: coreMQTT-Agent disconnected. Preventing coreMQTT-Agent commands from being enqueued.
I (25503) ota_over_mqtt_demo: coreMQTT-Agent disconnected. Suspending OTA agent.
I (25513) core_mqtt_agent_manager: coreMQTT-Agent disconnected.
I (25523) core_mqtt_agent_manager: TLS connection was disconnected.
I (27543) core_mqtt_agent_manager: TLS connection established.
I (27953) coreMQTT: MQTT connection established with the broker.
I (27953) core_mqtt_agent_manager: Session present: 1

I (27953) sub_pub_unsub_demo: coreMQTT-Agent connected.
I (27953) ota_over_mqtt_demo: coreMQTT-Agent connected. Resuming OTA agent.
I (27963) core_mqtt_agent_manager: coreMQTT-Agent connected.
I (28053) sub_pub_unsub_demo: Unsubscribe 6 for topic filter /filter/SubPub0 succeeded for task "SubPub0".
I (28053) sub_pub_unsub_demo: Task "SubPub0" completed a loop. Delaying before next loop.
E (29593) network_transport: Connection closed
E (29593) coreMQTT: Call to receiveSingleIteration failed. Status=MQTTRecvFailed
I (29593) sub_pub_unsub_demo: coreMQTT-Agent disconnected. Preventing coreMQTT-Agent commands from being enqueued.
I (29603) core_mqtt_agent_manager: TLS connection was disconnected.
I (29603) ota_over_mqtt_demo: coreMQTT-Agent disconnected. Suspending OTA agent.
I (29623) core_mqtt_agent_manager: coreMQTT-Agent disconnected.
I (31433) core_mqtt_agent_manager:

Diagnostic report archive.

No response

More Information.

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions