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

1.0.1 work fine with some patches but heap protection or queue managment needed in some #33

Open
poulch74 opened this issue Feb 9, 2021 · 7 comments

Comments

@poulch74
Copy link

poulch74 commented Feb 9, 2021

situations. for example when wifi performance is poor (it happens sometimes then about 30 wifi ap around me) i see in debug output about 100-150 elements in queue. it eats all heap, i see errors OUTBOUND_PUB_TOO_BIG and some next allocation fails with exception and reboot... about patches - i return back _destroyClient but replace delete -> close and patch ESPayncTCPwith issue "onAck hander not firing #160".

@wladwnt
Copy link

wladwnt commented Feb 20, 2021

Have probably the same issue. Do you mean you:

  1. patch ESPAsyncTCP with "set _tx_unacked_len to zero in void AsyncClient::_connected"?
  2. You call _destroyClient() in PangolinMQTT::_onDisconnect, and in _destroyClient() you close PANGO:TCP, so your code is:

`void PangolinMQTT::_destroyClient(){
if(PANGO::TCP) {
PANGO::TCP->onDisconnect([this](void* obj, AsyncClient* c) { }); // prevent recursion
delete PANGO::TCP; // causes a recurse!
PANGO::TCP=nullptr;
}
}

void PangolinMQTT::_hpDespatch(mb m){ if(_cbMessage) _cbMessage(m.topic.c_str(), m.payload, m.plen, m.qos, m.retain, m.dup); }

void PangolinMQTT::_onDisconnect(int8_t r) {
#if PANGO_DEBUG > 0
PANGO_PRINT1("ON DISCONNECT FH=%u r=%d\n",PANGO::_HAL_getFreeHeap(),r);
#endif
_connected=false;
PANGO::_clearQ(&PANGO::TXQ);
PANGO::_clearFragments();
PANGO::_nPollTicks=PANGO::_nSrvTicks=0;
if(PANGO::TCP){
_destroyClient();
if(_cbDisconnect) _cbDisconnect(r);
}
} `

@wladwnt
Copy link

wladwnt commented Feb 20, 2021

Does it make sense to check in application if PANGO::TXQ.size() is too high, then prevent new publish() ...

@poulch74
Copy link
Author

  1. yes
  2. no. in 1.0.1 PANGO::TCP reused so delete replaced with close()
    TXQ.size can be for example 10 but huge payload.. so i check GetFreeHeap and if it about 10000 - block publish.

@HamzaHajeir
Copy link

You can check H4AsyncMQTT, as it relies of a solid TCP client that Phil built its bases.

@poulch74
Copy link
Author

poulch74 commented Aug 2, 2023 via email

@proddy
Copy link

proddy commented Aug 2, 2023

I prefer clean PangolinMQTT without H4 dep… (the best solution for me PangolinMqtt+ EspAsyncTCP+ EspAsyncWebServer with websocket support) but in fact now in my current project I use  https://github.com/bertmelis/espMqttClient  

same here. It has a smaller footprint which is critical to my project.

@HamzaHajeir
Copy link

HamzaHajeir commented Aug 2, 2023 via email

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

No branches or pull requests

4 participants