Replies: 7 comments 14 replies
-
Invalid operation of SSL client. You have to debug your code because the SSL client is not in the state that is ready to send data but you are trying to use it to send data e.g. it is in the state that it is waiting to receive data. This is the user code error. |
Beta Was this translation helpful? Give feedback.
-
The important thing is that a SSL client used in one async client, must not be shared with other async clients. Please read the documentation for how the async client works. |
Beta Was this translation helpful? Give feedback.
-
The PUT... is serial print I see on terminal (It is write after a
Database.set<...> )
Il giorno lun 24 giu 2024 alle ore 10:43 Suwatchai K. <
***@***.***> ha scritto:
… The error is because of your code I can do nothing without code.
Where? Library does not provide such this debug.
In debug I see:
PUT /Data-Devices/test-1/DateTimePing.json?auth=<____
_____________>
—
Reply to this email directly, view it on GitHub
<#99 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BJMXA5UCBXBQZXH4W3KSA7DZI7LZXAVCNFSM6AAAAABJYUO2HSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TQNJXHE2DM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Biagio Meirone
|
Beta Was this translation helpful? Give feedback.
-
In your case, please try to update ESP32 Arduino Core first. This is the example that uses 3 async clients for Stream and 3 async clients for set operation. This runs fine on ESP32 Core v3.0.1. #include <Arduino.h>
#include <WiFi.h>
#include <FirebaseClient.h>
#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"
#define API_KEY "Web_API_KEY"
#define USER_EMAIL "USER_EMAIL"
#define USER_PASSWORD "USER_PASSWORD"
#define DATABASE_URL "URL"
void asyncCB(AsyncResult &aResult);
void printResult(AsyncResult &aResult);
DefaultNetwork network;
UserAuth user_auth(API_KEY, USER_EMAIL, USER_PASSWORD);
FirebaseApp app;
WiFiClient basic_client1, basic_client2, basic_client3, basic_client4, basic_client5, basic_client6;
ESP_SSLClient ssl_client1, ssl_client2, ssl_client3, ssl_client4, ssl_client5, ssl_client6;
using AsyncClient = AsyncClientClass;
AsyncClient aClient1(ssl_client1, getNetwork(network)), aClient2(ssl_client2, getNetwork(network)), aClient3(ssl_client3, getNetwork(network)), aClient4(ssl_client4, getNetwork(network)), aClient5(ssl_client5, getNetwork(network)), aClient6(ssl_client6, getNetwork(network));
RealtimeDatabase Database;
unsigned long ms1 = 0, ms2 = 0;
void setup()
{
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(300);
}
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
Firebase.printf("Firebase Client v%s\n", FIREBASE_CLIENT_VERSION);
Serial.println("Initializing app...");
ssl_client1.setClient(&basic_client1);
ssl_client2.setClient(&basic_client2);
ssl_client3.setClient(&basic_client3);
ssl_client4.setClient(&basic_client4);
ssl_client5.setClient(&basic_client5);
ssl_client6.setClient(&basic_client6);
ssl_client1.setInsecure();
ssl_client2.setInsecure();
ssl_client3.setInsecure();
ssl_client4.setInsecure();
ssl_client5.setInsecure();
ssl_client6.setInsecure();
ssl_client1.setBufferSizes(2048, 1024);
ssl_client2.setBufferSizes(2048, 1024);
ssl_client3.setBufferSizes(2048, 1024);
ssl_client4.setBufferSizes(2048, 1024);
ssl_client5.setBufferSizes(2048, 1024);
ssl_client6.setBufferSizes(2048, 1024);
ssl_client1.setDebugLevel(1);
ssl_client2.setDebugLevel(1);
ssl_client3.setDebugLevel(1);
ssl_client4.setDebugLevel(1);
ssl_client5.setDebugLevel(1);
ssl_client6.setDebugLevel(1);
initializeApp(aClient6, app, getAuth(user_auth), asyncCB, "authTask");
app.getApp<RealtimeDatabase>(Database);
Database.url(DATABASE_URL);
Database.setSSEFilters("get,put,patch,keep-alive,cancel,auth_revoked");
Database.get(aClient1, "/test/stream/path1", asyncCB, true /* SSE */, "streamTask1");
Database.get(aClient2, "/test/stream/path2", asyncCB, true /* SSE */, "streamTask2");
Database.get(aClient3, "/test/stream/path3", asyncCB, true /* SSE */, "streamTask3");
}
void loop()
{
app.loop();
Database.loop();
if (millis() - ms1 > 3000 && app.ready())
{
ms1 = millis();
JsonWriter writer;
Database.set<int>(aClient4, "/test/stream/path1/number", random(100, 199), asyncCB, "setTask1");
Database.set<int>(aClient5, "/test/stream/path2/number", random(200, 299), asyncCB, "setTask2");
Database.set<int>(aClient6, "/test/stream/path2/number", random(300, 399), asyncCB, "setTask3");
}
if (millis() - ms2 > 5000 && app.ready())
{
ms2 = millis();
Database.set<int>(aClient4, "/test/stream/path1/number", random(400, 499), asyncCB, "setTask4");
Database.set<int>(aClient5, "/test/stream/path3/number", random(500, 599), asyncCB, "setTask5");
Database.set<int>(aClient6, "/test/stream/path3/number", random(600, 699), asyncCB, "setTask6");
}
}
void asyncCB(AsyncResult &aResult)
{
printResult(aResult);
}
void printResult(AsyncResult &aResult)
{
if (aResult.isEvent())
{
Firebase.printf("Event task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.appEvent().message().c_str(), aResult.appEvent().code());
}
if (aResult.isDebug())
{
Firebase.printf("Debug task: %s, msg: %s\n", aResult.uid().c_str(), aResult.debug().c_str());
}
if (aResult.isError())
{
Firebase.printf("Error task: %s, msg: %s, code: %d\n", aResult.uid().c_str(), aResult.error().message().c_str(), aResult.error().code());
}
if (aResult.available())
{
RealtimeDatabaseResult &RTDB = aResult.to<RealtimeDatabaseResult>();
if (RTDB.isStream())
{
Serial.println("----------------------------");
Firebase.printf("task: %s\n", aResult.uid().c_str());
Firebase.printf("event: %s\n", RTDB.event().c_str());
Firebase.printf("path: %s\n", RTDB.dataPath().c_str());
Firebase.printf("data: %s\n", RTDB.to<const char *>());
Firebase.printf("type: %d\n", RTDB.type());
}
else
{
Serial.println("----------------------------");
Firebase.printf("task: %s, payload: %s\n", aResult.uid().c_str(), aResult.c_str());
}
Firebase.printf("Free Heap: %d\n", ESP.getFreeHeap());
}
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation!!
Il giorno lun 24 giu 2024 alle ore 14:42 Suwatchai K. <
***@***.***> ha scritto:
… That is a known bug in ESP32 WiFiClient as I mentioned in documentation
about issue in the old Firebase library that the ESP_SSLClient and
WiFiClient was used internally as a client, when remote server closes the
connection while the ssl_client.connected() still returned true.
This bug related to WiFiClient's peek() function.
Because of TCP session was reused (keep alive), you have to close the
connection using basic_client.stop() or ssl_client_stop() at least when
it was connected in more than two minutes. I'm not recommend you stop the
client every time before you call set because it takes time to do TLS
handshake.
You can prove my statement by print the connection status of WiFiClient
before calling set.
Serial.println(basic_client.connected());
And it may fix in ESP32 Arduino Core v3.0.2 as there is someone pull
request fix on ESP32 repo.
—
Reply to this email directly, view it on GitHub
<#99 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BJMXA5WTUECOVWNVK3SAAD3ZJAH25AVCNFSM6AAAAABJYUO2HSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TQNRQGI2DS>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Biagio Meirone
|
Beta Was this translation helpful? Give feedback.
-
Instead of manually stop the SSL Client, you can update the library to v1.2.16 which will limit the session timeout to avoid this |
Beta Was this translation helpful? Give feedback.
-
Hi,
I try the 1.2.16 but continue to receive the same error.
Above the debug info:
INFO.mUpdateEngine: State SENDREC
INFO.mUpdateEngine: State Connection close
WARN.mRunUntil: Terminating because the ssl engine closed.
ERROR.write: Failed while waiting for the engine to enter BR_SSL_SENDAPP.
INFO.mConnectBasicClient: Basic client connected!
INFO.mConnectSSL: Start connection.
INFO.mConnectSSL: Wait for SSL handshake.
INFO.mUpdateEngine: State RECVREC
INFO.mUpdateEngine: State RECVREC
INFO.mRunUntil: SSL state changed.
INFO.mRunUntil: State RECVREC
INFO.mRunUntil: Expected bytes count: 5
INFO.mUpdateEngine: State RECVREC
INFO.mUpdateEngine: State RECVREC
INFO.mUpdateEngine: State SENDAPP
INFO.mRunUntil: SSL state changed.
INFO.mRunUntil: State SENDAPP
Il giorno mar 25 giu 2024 alle ore 14:58 Suwatchai K. <
***@***.***> ha scritto:
… Closed #99 <#99> as
resolved.
—
Reply to this email directly, view it on GitHub
<#99>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BJMXA5RXYTG627L6L4OASJDZJFSOBAVCNFSM6AAAAABJYUO2HSVHI2DSMVQWIX3LMV45UABFIRUXGY3VONZWS33OIV3GK3TUHI5E433UNFTGSY3BORUW63R3GEZTKNRRHEZQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
.com>
--
Biagio Meirone
|
Beta Was this translation helpful? Give feedback.
-
Hi,
i have 2 SSE on firebase database entity and sometimes (every 3 minutes) i write with a different async client to another entity of database but I take this error:
so the data are not update..
for esample the code that generate the problem is:
Database.set(aClient6, "/data/" + myiddevice+ "/DateTimePing", time, aResult_no_callback);
any suggestion in what I'm wrong?
Beta Was this translation helpful? Give feedback.
All reactions