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

It steals memory from other functions #1011

Open
AB-informatica-service opened this issue May 4, 2023 · 0 comments
Open

It steals memory from other functions #1011

AB-informatica-service opened this issue May 4, 2023 · 0 comments

Comments

@AB-informatica-service
Copy link

Hi every one,

As recommended this using SSLClient to connect with MQTT Broker, I increased the library buffer:
//unsigned char m_iobuf[2048];
unsigned char m_iobuf[BR_SSL_BUFSIZE_BIDI];

As recommended herei: #OPEnSLab-OSU/SSLClient#46

My code is:
SSLClientParameters mTLS = SSLClientParameters::fromPEM(AWS_CERT_CRT, sizeof AWS_CERT_CRT, AWS_CERT_PRIVATE, sizeof AWS_CERT_PRIVATE);
this->sslClient->setMutualAuthParams(mTLS);

Dopo la creazione del Client faccio:
this->mqtt = new PubSubClient(AWS_IOT_ENDPOINT, 8883, AbiotMQTT::subscribeHandler, this->client);
`while (!mqtt->connect(BROKER_ID))
{
Serial.print(".");
log_e("Impossibile connettersi al broker MQTT");
return false;
}

log_e("Iscrizione al topic %s", TOPIC_SUB);
while (!mqtt->subscribe(TOPIC_SUB))
{
    Serial.print(".");
    delay(500);
}
delay(100);

log_i("Connesso al broker: %s ", String(mqtt->connected()).c_str());
mqtt->setBufferSize(MQTT_PACKET_SIZE);
return mqtt->connected();`

Now I have the problem that ESP32-S3 PIN 17 remains HIGH after object creation and on this pin I run a LoRa TX modem (I use it only to transmit).
I noticed that if before using this modem create the modem object again, it works. But it is not normal that I have to recreate the LoRa modem object every time.

Also after some time (about 30 min) I have problems with SSL and I have to reconnect to the Broker, the serial monitor says this:

(SSLClient)(SSL_ERROR)(m_update_engine): Error writing to m_client
(SSLClient)(SSL_ERROR)(m_update_engine): 0
(SSLClient)(SSL_WARN)(connected): Socket was dropped unexpectedly (this can be an alternative to closing the connection)
[1323214] ### Unhandled: +PDP: DEACT

0, SEND FAIL

+SAPBR 1: DEACT
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
(SSLClient)(SSL_ERROR)(available): SSL engine failed to update.
[1325641][I][AbiotClient.cpp:576] loop(): Network disconnected
[1329720][I][AbiotClient.cpp:587] loop(): GPRS disconnected!
[1329720][I][AbiotClient.cpp:588] loop(): Connecting to
[1329720][I][AbiotClient.cpp:589] loop(): iot.truphone.com
[1330188] ### Daylight savings time state updated.
[1330229] ### Network time and time zone updated.
[1333049] ### Daylight savings time state updated.
[1333090] ### Network time and time zone updated.
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
[1334042][I][AbiotMQTT.cpp:65] loop(): Connessione con broker MQTT disconnesso
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
(SSLClient)(SSL_ERROR)(connected): Not connected because write error is set
(SSLClient)(SSL_ERROR)(m_print_ssl_error): SSL_CLIENT_WRITE_FAIL
[1349176][E][AbiotMQTT.cpp:79] loop(): Iscrizione al topic abiot/6e3dadf2-0edf-4ac2-b94d-5128aff877d0
[1349287][I][AbiotMQTT.cpp:87] loop(): Connesso al broker: 1

I did some tests: if I exclude the LoRa TX modem, these SSL errors never come out.
Conversely, if I exclude SSL and therefore do not use MQTT, the LoRa modem always works fine without recreating the modem object before each transmission.

In my mind it seems like they don't have enough space and they steal each other's memory, I checked how much RAM I have available and I always have at least 202556 bytes (according to esp_get_free_heap_size()).

This goes out of my knowledge, I ask for support.

Thank you

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

1 participant