Skip to content

MQTT poor performance #6543

Closed
Closed
@FStefanni

Description

@FStefanni

Board

esp32 dev module

Device Description

esp32 devkit c v4

Hardware Configuration

  • I2C sensors
  • I2C display SSD1306

Version

v2.0.2

IDE Name

VS Code + arduino-cli

Operating System

Linux Debian Testing

Flash frequency

default

PSRAM enabled

no

Upload speed

default

Description

Hi,

I try to summarize in the following.

The program

  • ESP32 configuration:
    • ESP32 attached to WiFi
    • ESP32 attached to a MQTT broker
  • ESP32 during its loop:
    • At periodic timeout
      • Show into the display a different information page (i.e. cycle through available pages)
      • Available pages are:
        • Sensors data
        • WiFi information (ssid, rssi, ip, mode)
    • If a mqtt message arrives
      • Publish a message with sensors data

The issue

The reply to the MQTT message can be very slow, till 11 seconds.
Also, the response to a simple network ping is sometimes very slow (more than 1 second).

The workaround

I have found that the calling of the WiFi methods to retrieve the information to display are the origin of the slowdown.
So, if I avoid to call them when I display the page (i.e. I read them only once during the setup() and then I show the "preloaded" values), everything works fine (immediate MQTT reply, ping avg near to 300ms).
The methods are:

  • WiFi.RSSI()
  • WiFi.localIP()
  • WiFi.SSID()
  • WiFi.getMode()
  • Maybe also the "AP alter ego methods" have the same issue (not tested):
    • WiFi.softAPSSID()
    • WiFi.softAPIP()

I have seen that the Arduino ESP32 is not a plain wrapper to ESP-IDF methods, but it also adds some logic, so I do not know whether the issue is in the Arduino layer or the ESP-IDF methods.

FYI, also the Arduino ESP32 version 2.0.0 has the same issue, and the same workaround works as well.

Regards.

Sketch

Not possible to share.

Debug Message

No message available

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Activity

VojtechBartoska

VojtechBartoska commented on Apr 7, 2022

@VojtechBartoska
Contributor

Hello @FStefanni, are you able to test this on v2.0.3-RC1 as well? Thanks

FStefanni

FStefanni commented on Apr 7, 2022

@FStefanni
Author

Hi,

I can, if someone tells me how to do it: it is not available in arduino ide for install.

Regards.

VojtechBartoska

VojtechBartoska commented on Apr 7, 2022

@VojtechBartoska
Contributor

Take a look here: https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html

You need to change your link in Preferences in Arduino IDE to development release link.

FStefanni

FStefanni commented on Apr 7, 2022

@FStefanni
Author

Hi,

thank you for the hints.
I checked, and yes, there is still the same behavior, maybe it happens slightly less frequent, but it still happen to have a delay around 11s/13s.

NOTE: something strange happens during compiling with 2.0.3-RC1: the first compilation fails, but the second succeeds... maybe something to be adjusted into my project? Nevertheless, as the second consecutive compiling goes fine, I used that to do the check.

Regards

SuGlider

SuGlider commented on Apr 18, 2022

@SuGlider
Collaborator

I suggest to turn on debug output using Core Debug Level: "Verbose" on the Arduino IDE Menu->Tools->Core Debug Level
It may help to see some messages that may help to debug the issue.

podaen

podaen commented on May 1, 2022

@podaen

Same here #6664

SuGlider

SuGlider commented on May 2, 2022

@SuGlider
Collaborator

Please refer to these two commentaries:

#6664 (comment)
#6664 (comment)

FStefanni

FStefanni commented on May 2, 2022

@FStefanni
Author

Hi,

regarding issue #6664, I believe in my case it is something different, since it was polling the WiFi status which was degrading the WiFi performance (please refer to the workaround section of this issue).

To fix (or understand) my issue, we should look the implementation of the involved methods... and this requires someone who knows that code -- but unfortunately it is not me.

Regards

podaen

podaen commented on May 2, 2022

@podaen

Without code it's harder to understand what you are doing. Did you tried the event for the wifi status?

For the MQTT I did already managed to send fast messages to the Hive broker (not tested from the broker). However this was in SDK 1.0.6, using pubsubclient-master.h. And the message size was not longer than 40bytes.

self-assigned this
on May 3, 2022
SuGlider

SuGlider commented on May 3, 2022

@SuGlider
Collaborator

@FStefanni

The reply to the MQTT message can be very slow, till 11 seconds.

Can you please provide more information. What is the topology? Which server? Is there any simple sketch that we can test and see the issue happening?

Also, the response to a simple network ping is sometimes very slow (more than 1 second).

Ping is something relative to all the elements in the network as well as the current traffic at the time ping is executed.
We need more information about topology and connections.

27 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    MQTT poor performance · Issue #6543 · espressif/arduino-esp32