Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guru Meditation in ReaderMqttPacket::bytesToString when there is some traffic load on the Broaker #6

Open
diodi opened this issue Dec 26, 2022 · 5 comments

Comments

@diodi
Copy link

diodi commented Dec 26, 2022

I modified httpServerAndMqttBroker.ino to operate as as WIFI_AP and to allow up to 8 clients.

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>
#include "EmbeddedMqttBroker.h"
...

void setup(){

  Serial.begin(115200);
  Serial.println();
  Serial.println("Configuring access point...");

  WiFi.mode(WIFI_AP);  
  WiFi.softAP(ssid, password);
  delay(500);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);

  // Start http server
  server.begin();
...

  // Start the mqtt broker
  broker.setMaxNumClients(8); // set according to your system.
  broker.startBroker();
  Serial.println("broker started"

Connecting two clients and generating some trafic I run into an unhandled exception.

publishing: moba/ToESP
enviando publish
enviando publish
publishing: moba/ToESP
enviando publish
enviando publish
no action
no action
no action
no action
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

The memcopy operation

int ReaderMqttPacket::bytesToString(int index, size_t textFieldLengt,String*textField){
    // reserving memory to copy the mqtt text field.
    char* aux = (char*)malloc(textFieldLengt+1);

    // memcpy is necesary because reader object will be deleted.
    memcpy(aux,&remainingPacket[index],textFieldLengt);

leads to the exception.

Please let me know if you need more. Thank you!

@alexCajas
Copy link
Owner

ok! it is a important issue, I will fix it.

@alexCajas
Copy link
Owner

Hi again, @diodi , can you give information about the clients please? Desktops clients, esp clients maybe?, Is the traffic only two publish?

@diodi
Copy link
Author

diodi commented Jan 11, 2023

Two esp clients are active. Both publish serialized JsonDocuments (ArduinoJson.h) to several sub-topics within the same main topic using PubSubClientStatic. Both clients subscribe to the main topic to receive all published information. Thank you for taking a look.

@rolliracker
Copy link

I get the same error as described by @diodi. But I also get it without running an Access Point. I use the simpleMqttBroker example with
WiFi.mode(WIFI_STA);
and with only one client that publishes two topics every 10 seconds (Tasmota on an ESP8266).

When I print out the free memory with
ESP.getFreeHeap()
I see decreasing free memory after each publication event.

The time until the exception occurs varies, but often is only a couple of minutes. I tried version 1.0.5 and 1.0.3 with basically the same result

@lutorm
Copy link

lutorm commented Oct 29, 2024

I wonder if I'm seeing the same problem. I'm running SimpleMqqtBroker in STA mode, with 2 clients publishing and 2 subscribing. After about 10 minutes, the broker repeatably drops off the network. There is nothing printed on the serial when this happens, do you have to do something to enable the core panic message above?

Edit: my issue seems different so I made another issue: #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

4 participants