-
Notifications
You must be signed in to change notification settings - Fork 135
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
The connection to MQTT Backend is not working when trying to use mutual TLS connection (IDFGH-9828) #272
Comments
2 Topics |
1 similar comment
2 Topics |
|
2. Topic: why does it crash ? i mean a full Quque can bring up a Error, Exception what else, but not a Crash ? |
I was able to reproduce the
Flow control signals (RTS/CTS) work together with the UART peripheral HW. But the UART driver needs to pass the incoming data to user task (via FreeRTOS queues) and that seemed to overflow. And the reason for that is IMO the extensive logging on verbose level, e.g. for every byte that we send to one UART (and we send a lot during TLS handshake with mutual authentication) we print ~ 3 characters to another UART. dte_config.uart_config.event_queue_size = 128;
This looks like a bug, somewhere, but wasn't able to reproduce it. |
When TLS is disabled and the embedded MQTT client uses just authentication with username and password, then the problem is not observed. |
This is clear as the TLS connection requires far more bandwidth. It is also expected to see some SW event queue overflows as explained above. |
Hi, @david-cermak here is a Sample where you see the Crash: it is fully based on your Sample, with only the minimalst changes. see log here: https://gist.github.com/diplfranzhoepfinger/509d39e4b4115efcc84a2865c7ed60c1 maybe this log even better: |
How often do you see the failure? I ran your sample application (4a6e55d51a097c44c346160a00e6d3ddb47a14bf with IDF v5.0.2), ran it several times, tried to decrease stack sizes, played a bit, but no crashes seen (the only thing I changed was Tx/Rx and my APN, tested with SIM7600)
|
immediately and every time.
OK. i could give it a Test too with 7600 ... worth it ? maybe we have some speciality in the A7276
no, all checked in. 100% sure. did you test with A7276 or a different Modem ?
i can. could it then also work with the 2nd Modem Model ? |
@diplfranzhoepfinger Tested with A7672 and was able to reproduce the issue. The problem is an internal buffer overflow, which is not currently checked for in Thank you for taking the time and effort to create this simple example! You can disable |
cooooooooool
ahhhhhhhhhhhhh.
very good.
yes, i was also thinking this is the only way forward.
what negative side effects does this bring ? |
so, tested: after this Commit, the Crash is gone. |
> Hi @diplfranzhoepfinger done with Commit lets see if this helps |
#180 <-- Discuss URC there. |
Hi, seems to fragment Answers from the Modem in the CMUX Terminal which is in AT Mode, we will provide you a log about this. |
Hi Franz, I'm sorry, haven't thought of that. This is quite possible if the command terminal outputs longer payload. diff --git a/components/esp_modem/src/esp_modem_cmux.cpp b/components/esp_modem/src/esp_modem_cmux.cpp
index 0c480f8..283d486 100644
--- a/components/esp_modem/src/esp_modem_cmux.cpp
+++ b/components/esp_modem/src/esp_modem_cmux.cpp
@@ -120,13 +120,17 @@ void CMux::data_available(uint8_t *data, size_t len)
if (virtual_term < MAX_TERMINALS_NUM && read_cb[virtual_term]) {
// Post partial data (or defragment to post on CMUX footer)
#ifdef DEFRAGMENT_CMUX_PAYLOAD
- if (payload_start == nullptr) {
- payload_start = data;
- total_payload_size = 0;
+ if (virtual_term == 0) { // no need to defragment term network data (term=0), PPP takes care of that
+ read_cb[virtual_term](data, len);
+ } else {
+ if (payload_start == nullptr) {
+ payload_start = data;
+ total_payload_size = 0;
+ }
+ total_payload_size += len;
}
- total_payload_size += len;
#else
- read_cb[virtual_term](data, len);
+
#endif
}
} else if (data == nullptr && type == 0x73 && len == 0) { // notify the initial SABM command
@@ -136,7 +140,9 @@ void CMux::data_available(uint8_t *data, size_t len)
int virtual_term = dlci - 1;
if (virtual_term < MAX_TERMINALS_NUM && read_cb[virtual_term]) {
#ifdef DEFRAGMENT_CMUX_PAYLOAD
- read_cb[virtual_term](payload_start, total_payload_size);
+ if (payload_start) {
+ read_cb[virtual_term](payload_start, total_payload_size);
+ }
#endif
}
} else if ((type & FT_UIH) == FT_UIH && dlci == 0) { // notify the internal DISC command and test again? With This change makes the modem to defragment only command data, as the network data are in PPP format which already uses start/end markers. Alternatively we can extend buffer sizes and defragment everything, but that would probably mean an unnecessary waste of RAM, especially if your device could post few kilobytes each fragment of CMUX payload. |
This is looks like a memory corruption and is probably caused by the proposed patch in #272 (comment) (there might still be issue when defragmenting two byte payloads on static buffer which is far less than the max payload) you can increase the buffer size ( |
As a configurable option, if disabled we report an error. Closes espressif#272
is the Standard now ... |
does it mean we should combine #272 (comment) and #312 or should we take back #272 (comment) ??? |
Please, use just the fixes in #312 -- this is the official fix of addressing issues with CMUX protocols with 2 byte payloads.
That would basically disable defragmentation on CMUX layer (which won't work reliably with your device), but enable defragmenting of AT replies on DTE layer) (#272 (comment) was just a quick patch, which might fix some problems, but may introduce others) |
Tnx. |
Hi, i merged your changes here: and this is the Log: it seems it is no more getting an IP Address. |
Crazy: somtimes ... |
so, i compare now 2 Stages: I. and II. at I. i get never the at II. i get the so something must be not OK with #312 . @david-cermak any idea ? |
did a cross test after testing I. with II. and immediately same Problem, after 5 Times no Problem with I. https://gist.github.com/diplfranzhoepfinger/c7124d0536702eea5d6ac3090b0ff7b8 |
we have another Project: there we had #312 integrated, and courious: there we get a IP always, but after getting IP the AT Commands which reply more than a OK are no more forwarded. see Log: https://gist.github.com/diplfranzhoepfinger/79907f9f5254b58872dd564c8e2889e7 here i have committed the Loggers diplfranzhoepfinger/esp-protocols-tree-master-components-esp_modem-examples-simple_cmux_client@2b7a1db but the Project is a different one, which cannot be shared. so we have: Project II. like mentioned above: seldom get IP Project "secret" which always get IP but no AT Communication after got IP. Thanks Franz |
gave you another Log: https://gist.github.com/diplfranzhoepfinger/b7b9b0366ec2897edf24edddec614185 we see that the Log-Output
does come in the Beginning, Thanks, |
As a configurable option, if disabled we report an error. Closes espressif#272
As a configurable option, if disabled we report an error. Closes espressif#272
As a configurable option, if disabled we report an error. Closes espressif#272
1.0.2 Features - Add factory method for simple creation of custom DCEs (4cf9e50) - Support custom transport in AT TCP client example (ae629ed) Bug Fixes - Fix host test race with async read and d'structor (c89d42f) - More error handling in cmux protocol (8edbac6) - Fix netif to set PPP config in C++ way (5287432) - Fix vfs terminal not to reset read_cb() automatically (25a35e2) - Fix netif data race causing PPP startup delays (c8c0507, espressif#308) - Added support for inflatable buffer (cb6e03a, espressif#272) - Fix LoadProhibited after failed CMUX initialization (IDFGH-10845) (60c87dd)
Answers checklist.
What component are you using? If you choose Other, provide details in More Information.
esp_modem
component version
1.0.0
IDF version.
ESP-IDF Pre-release v5.0-rc1
More Information.
maybe a similar issue to this one:
#250
Tested on a SIMCOM A7672
Code: https://gist.github.com/franz-ms-muc/158ed5a1208c053403634eb5e3250a59
Log1: https://gist.github.com/franz-ms-muc/1e3699c361b82f92b399b268751f2ceb
Log2: https://gist.github.com/franz-ms-muc/3ddabeb29698d23eea524adb21b951c2
Log3: https://gist.github.com/franz-ms-muc/ed5179199a52c53d6361ff902b5c8070
The text was updated successfully, but these errors were encountered: