Skip to content

Commit 55a1326

Browse files
committed
Fix Token expiry bug which introduced in v4.3.0.
1 parent 7b0b211 commit 55a1326

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Firebase ESP32 Client",
3-
"version": "4.3.1",
3+
"version": "4.3.2",
44
"keywords": "communication, REST, esp32, arduino",
55
"description": "The secure, fast and reliable Firebase Realtime database library to read, store, update, delete, listen, backup, and restore data. You can also read and modify the database security rules with this library.",
66
"repository": {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name=Firebase ESP32 Client
22

3-
version=4.3.1
3+
version=4.3.2
44

55
author=Mobizt
66

src/FB_Utils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This library supports Espressif ESP8266, ESP32 and Raspberry Pi Pico (RP2040)
44
*
5-
* Created January 7, 2023
5+
* Created January 8, 2023
66
*
77
* This work is a part of Firebase ESP Client library
88
* Copyright (c) 2023 K. Suwatchai (Mobizt)
@@ -1688,7 +1688,6 @@ namespace TimeHelper
16881688
uint32_t &tm = *mb_ts;
16891689

16901690
#if defined(ESP8266) || defined(ESP32) || defined(PICO_RP2040)
1691-
if (tm < ESP_DEFAULT_TS)
16921691
tm = time(nullptr);
16931692
#else
16941693
tm = millis() / 1000;

src/Firebase.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* The Firebase class, Firebase.cpp v1.2.3
2+
* The Firebase class, Firebase.cpp v1.2.4
33
*
4-
* Created January 7, 2023
4+
* Created January 8, 2023
55
*
66
* The MIT License (MIT)
77
* Copyright (c) 2023 K. Suwatchai (Mobizt)
@@ -126,15 +126,21 @@ struct token_info_t Firebase_ESP_Client::authTokenInfo()
126126
bool Firebase_ESP_Client::ready()
127127
{
128128
#if defined(ESP32) || defined(ESP8266)
129-
// We need to close all data object TCP sessions when token was expired.
129+
// Stop the session only for ESPs to free the memory when token
130+
// expired (actually nearly expired) as the Signer needs memory
131+
// to open another secure TCP session to request new orrefresh token.
132+
// We don't stop session to free memory on other devices e,g, Pico as it uses
133+
// BearSSL engine that required less memory then it has enough free memory
134+
//to do other things.
130135
if (Signer.isExpired())
131136
{
132137
if (Signer.config)
133138
{
134139
for (size_t id = 0; id < Signer.config->internal.sessions.size(); id++)
135140
{
136141
FirebaseData *fbdo = addrTo<FirebaseData *>(Signer.config->internal.sessions[id]);
137-
if (fbdo && !fbdo->tcpClient.reserved)
142+
// non-stream used session will stop
143+
if (fbdo && !fbdo->tcpClient.reserved && fbdo->session.con_mode != fb_esp_con_mode_rtdb_stream)
138144
fbdo->closeSession();
139145
}
140146
}

src/Firebase.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
/**
3-
* The Firebase class, Firebase.h v1.2.3
3+
* The Firebase class, Firebase.h v1.2.4
44
*
5-
* Created January 7, 2023
5+
* Created January 8, 2023
66
*
77
* The MIT License (MIT)
88
* Copyright (c) 2023 K. Suwatchai (Mobizt)
@@ -2473,6 +2473,7 @@ class FIREBASE_CLASS
24732473
RTDB.setStreamCallback(&fbdo, dataAvailablecallback, timeoutCallback);
24742474
}
24752475
#endif
2476+
24762477
/** Set the multiple paths stream callback functions.
24772478
* setMultiPathStreamCallback should be called before Firebase.beginMultiPathStream.
24782479
*
@@ -2519,7 +2520,7 @@ class FIREBASE_CLASS
25192520
*/
25202521
void removeMultiPathStreamCallback(FirebaseData &fbdo) { RTDB.removeMultiPathStreamCallback(&fbdo); }
25212522

2522-
/** Run stream manually.
2523+
/** Run stream manually.
25232524
* To manually triggering the stream callback function, this should call repeatedly in loop().
25242525
*/
25252526
void runStream()

src/FirebaseESP32.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#ifndef FIREBASE_CLIENT_VERSION
2-
#define FIREBASE_CLIENT_VERSION "4.3.1"
2+
#define FIREBASE_CLIENT_VERSION "4.3.2"
33
#endif
44

55
/**
6-
* Google's Firebase Realtime Database Arduino Library for ESP32, v4.3.1
6+
* Google's Firebase Realtime Database Arduino Library for ESP32, v4.3.2
77
*
8-
* Created January 7, 2023
8+
* Created January 8, 2023
99
*
1010
* Updates:
11-
* - Bugs fixed.
12-
* - Code optimization.
13-
* - Add runStream function.
11+
* - Fix Token expiry bug which introduced in v4.3.0.
1412
*
1513
*
1614
* This library provides ESP32 to perform REST API by GET PUT, POST, PATCH,

0 commit comments

Comments
 (0)