Skip to content

Commit

Permalink
Fix RTDB stream time out error during authentication stage.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Jul 11, 2023
1 parent 0a81231 commit 270151b
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 112 deletions.
3 changes: 1 addition & 2 deletions src/FB_Const.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#endif

/**
* Created June 15, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -1894,7 +1894,6 @@ struct fb_esp_session_info_t
bool streaming = false;
bool buffer_ovf = false;
bool chunked_encoding = false;
bool connected = false;
bool classic_request = false;
MB_String host;
unsigned long last_conn_ms = 0;
Expand Down
18 changes: 5 additions & 13 deletions src/firestore/FB_Firestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

/**
* Google's Cloud Firestore class, Forestore.cpp version 1.2.8
* Google's Cloud Firestore class, Forestore.cpp version 1.2.9
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created July 10, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -510,7 +510,6 @@ bool FB_Firestore::sendRequest(FirebaseData *fbdo, struct fb_esp_firestore_req_t
return false;
}


if (Signer.config->internal.fb_processing)
return false;

Expand Down Expand Up @@ -755,14 +754,8 @@ bool FB_Firestore::firestore_sendRequest(FirebaseData *fbdo, struct fb_esp_fires
fbdo->tcpClient.send(req->payload.c_str());
}

if (fbdo->session.response.code > 0)
{
fbdo->session.connected = true;
if (fbdo->session.cfs.async || handleResponse(fbdo, req))
return true;
}
else
fbdo->session.connected = false;
if (fbdo->session.response.code > 0 && (fbdo->session.cfs.async || handleResponse(fbdo, req)))
return true;

return false;
}
Expand All @@ -771,8 +764,7 @@ void FB_Firestore::rescon(FirebaseData *fbdo, const char *host)
{
fbdo->_responseCallback = NULL;

if (fbdo->session.cert_updated || !fbdo->session.connected ||
millis() - fbdo->session.last_conn_ms > fbdo->session.conn_timeout ||
if (fbdo->session.cert_updated || millis() - fbdo->session.last_conn_ms > fbdo->session.conn_timeout ||
fbdo->session.con_mode != fb_esp_con_mode_firestore ||
strcmp(host, fbdo->session.host.c_str()) != 0)
{
Expand Down
4 changes: 2 additions & 2 deletions src/firestore/FB_Firestore.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

/**
* Google's Cloud Firestore class, Forestore.h version 1.2.8
* Google's Cloud Firestore class, Forestore.h version 1.2.9
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created July 10, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
10 changes: 3 additions & 7 deletions src/functions/FB_Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

/**
* Google's Cloud Functions class, Functions.cpp version 1.1.23
* Google's Cloud Functions class, Functions.cpp version 1.1.24
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created June 9, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -668,7 +668,6 @@ bool FB_Functions::functions_sendRequest(FirebaseData *fbdo, struct fb_esp_funct

if (fbdo->session.response.code > 0)
{
fbdo->session.connected = true;
if (req->requestType == fb_esp_functions_request_type_upload)
{
// Fix in ESP32 core 2.0.x
Expand Down Expand Up @@ -727,8 +726,6 @@ bool FB_Functions::functions_sendRequest(FirebaseData *fbdo, struct fb_esp_funct
return true;
}
}
else
fbdo->session.connected = false;

Signer.config->internal.fb_processing = false;
return false;
Expand All @@ -738,8 +735,7 @@ void FB_Functions::rescon(FirebaseData *fbdo, const char *host)
{
fbdo->_responseCallback = NULL;

if (fbdo->session.cert_updated || !fbdo->session.connected ||
millis() - fbdo->session.last_conn_ms > fbdo->session.conn_timeout ||
if (fbdo->session.cert_updated || millis() - fbdo->session.last_conn_ms > fbdo->session.conn_timeout ||
fbdo->session.con_mode != fb_esp_con_mode_functions || strcmp(host, fbdo->session.host.c_str()) != 0)
{
fbdo->session.last_conn_ms = millis();
Expand Down
4 changes: 2 additions & 2 deletions src/functions/FB_Functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

/**
* Google's Cloud Functions class, Functions.h version 1.1.23
* Google's Cloud Functions class, Functions.h version 1.1.24
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created June 9, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
12 changes: 5 additions & 7 deletions src/gcs/GCS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

/**
* Google's Cloud Storage class, GCS.cpp version 1.2.9
* Google's Cloud Storage class, GCS.cpp version 1.2.10
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created June 9, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -279,8 +279,7 @@ void GG_CloudStorage::rescon(FirebaseData *fbdo, const char *host)
{
fbdo->_responseCallback = NULL;

if (fbdo->session.cert_updated || !fbdo->session.connected ||
millis() - fbdo->session.last_conn_ms > fbdo->session.conn_timeout ||
if (fbdo->session.cert_updated || millis() - fbdo->session.last_conn_ms > fbdo->session.conn_timeout ||
fbdo->session.con_mode != fb_esp_con_mode_gc_storage || strcmp(host, fbdo->session.host.c_str()) != 0)
{
fbdo->session.last_conn_ms = millis();
Expand Down Expand Up @@ -579,7 +578,7 @@ bool GG_CloudStorage::gcs_sendRequest(FirebaseData *fbdo, struct fb_esp_gcs_req_
multipart_header2 += boundary;
multipart_header2 += fb_esp_gcs_pgm_str_13; // "--"

header += fb_esp_pgm_str_33; // "Content-Type: "
header += fb_esp_pgm_str_33; // "Content-Type: "
header += fb_esp_gcs_pgm_str_14; // "multipart/related; boundary="
header += boundary;
HttpHelper::addNewLine(header);
Expand Down Expand Up @@ -669,7 +668,6 @@ bool GG_CloudStorage::gcs_sendRequest(FirebaseData *fbdo, struct fb_esp_gcs_req_
{

fbdo->session.gcs.storage_type = req->storageType;
fbdo->session.connected = true;
if (req->requestType == fb_esp_gcs_request_type_upload_simple ||
req->requestType == fb_esp_gcs_request_type_upload_multipart)
{
Expand Down Expand Up @@ -790,7 +788,7 @@ bool GG_CloudStorage::gcs_sendRequest(FirebaseData *fbdo, struct fb_esp_gcs_req_
Signer.mbfs->close(mbfs_type req->storageType);
}

if (fbdo->session.connected)
if (fbdo->tcpClient.connected())
{
bool ret = handleResponse(fbdo, req);
fbdo->closeSession();
Expand Down
4 changes: 2 additions & 2 deletions src/gcs/GCS.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

/**
* Google's Cloud Storage class, GCS.h version 1.2.9
* Google's Cloud Storage class, GCS.h version 1.2.10
*
* This library supports Espressif ESP8266, ESP32 and RP2040 Pico
*
* Created June 9, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
31 changes: 14 additions & 17 deletions src/message/FCM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

/**
* Google's Firebase Cloud Messaging class, FCM.cpp version 1.0.31
* Google's Firebase Cloud Messaging class, FCM.cpp version 1.0.32
*
* This library supports Espressif ESP8266 and ESP32
*
* Created June 9, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -235,7 +235,7 @@ bool FB_CM::sendHeader(FirebaseData *fbdo, fb_esp_fcm_msg_mode mode, const char
}
else if (mode == fb_esp_fcm_msg_mode_apn_token_registration)
{
header += fb_esp_fcm_pgm_str_5; // "/iid/v1"
header += fb_esp_fcm_pgm_str_5; // "/iid/v1"
header += fb_esp_fcm_pgm_str_15; // ":batchImport"
}
}
Expand Down Expand Up @@ -495,7 +495,7 @@ void FB_CM::fcm_prepareV1Payload(FCM_HTTPv1_JSON_Message *msg)
{
s = Utils::makeFCMMessagePath();
s += fb_esp_fcm_pgm_str_43; // "fcm_options"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_44; // "analytics_label"
json.set(s, msg->fcm_options.analytics_label);
}
Expand Down Expand Up @@ -542,7 +542,7 @@ void FB_CM::fcm_prepareV1Payload(FCM_HTTPv1_JSON_Message *msg)
{
s = Utils::makeFCMMessagePath();
Utils::addFCMAndroidPath(s, fb_esp_fcm_pgm_str_43 /* "fcm_options" */);
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_44; // "analytics_label"
json.set(s, msg->android.fcm_options.analytics_label);
}
Expand Down Expand Up @@ -747,31 +747,31 @@ void FB_CM::fcm_prepareV1Payload(FCM_HTTPv1_JSON_Message *msg)
{
s = base;
s += fb_esp_fcm_pgm_str_35; // "color"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_59; // "red"
json.set(s, atoi(msg->android.notification.light_settings.color.red.c_str()));
}
if (msg->android.notification.light_settings.color.green.length() > 0)
{
s = base;
s += fb_esp_fcm_pgm_str_35; // "color"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_60; // "green"
json.set(s, atoi(msg->android.notification.light_settings.color.green.c_str()));
}
if (msg->android.notification.light_settings.color.blue.length() > 0)
{
s = base;
s += fb_esp_fcm_pgm_str_35; // "color"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_61; // "blue"
json.set(s, atoi(msg->android.notification.light_settings.color.blue.c_str()));
}
if (msg->android.notification.light_settings.color.alpha.length() > 0)
{
s = base;
s += fb_esp_fcm_pgm_str_35; // "color"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_62; // "alpha"
json.set(s, atoi(msg->android.notification.light_settings.color.alpha.c_str()));
}
Expand Down Expand Up @@ -820,7 +820,7 @@ void FB_CM::fcm_prepareV1Payload(FCM_HTTPv1_JSON_Message *msg)
{
s = Utils::makeFCMMessagePath();
Utils::addFCMWebpushPath(s, fb_esp_fcm_pgm_str_43 /* "fcm_options" */);
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_44; // "analytics_label"
json.set(s, msg->webpush.fcm_options.analytics_label);
}
Expand All @@ -829,7 +829,7 @@ void FB_CM::fcm_prepareV1Payload(FCM_HTTPv1_JSON_Message *msg)
{
s = Utils::makeFCMMessagePath();
Utils::addFCMWebpushPath(s, fb_esp_fcm_pgm_str_43 /* "fcm_options" */);
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_66; // "link"
json.set(s, msg->webpush.fcm_options.link);
}
Expand All @@ -856,7 +856,7 @@ void FB_CM::fcm_prepareV1Payload(FCM_HTTPv1_JSON_Message *msg)
{
s = Utils::makeFCMMessagePath();
Utils::addFCMApnsPath(s, fb_esp_fcm_pgm_str_43 /* "fcm_options" */);
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_44; // "analytics_label"
json.set(s, msg->apns.fcm_options.analytics_label);
}
Expand All @@ -865,7 +865,7 @@ void FB_CM::fcm_prepareV1Payload(FCM_HTTPv1_JSON_Message *msg)
{
s = Utils::makeFCMMessagePath();
Utils::addFCMApnsPath(s, fb_esp_fcm_pgm_str_43 /* "fcm_options" */);
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_pgm_str_1; // "/"
s += fb_esp_fcm_pgm_str_42; // "image"
json.set(s, msg->apns.fcm_options.image);
}
Expand Down Expand Up @@ -911,8 +911,6 @@ bool FB_CM::fcm_send(FirebaseData *fbdo, fb_esp_fcm_msg_mode mode, const char *m
Signer.config->internal.fb_processing = false;
return false;
}
else
fbdo->session.connected = true;

ret = waitResponse(fbdo);

Expand Down Expand Up @@ -974,8 +972,7 @@ void FB_CM::rescon(FirebaseData *fbdo, const char *host)
{
fbdo->_responseCallback = NULL;

if (fbdo->session.cert_updated || !fbdo->session.connected ||
millis() - fbdo->session.last_conn_ms > fbdo->session.conn_timeout ||
if (fbdo->session.cert_updated || millis() - fbdo->session.last_conn_ms > fbdo->session.conn_timeout ||
fbdo->session.con_mode != fb_esp_con_mode_fcm ||
strcmp(host, fbdo->session.host.c_str()) != 0)
{
Expand Down
4 changes: 2 additions & 2 deletions src/message/FCM.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#endif

/**
* Google's Firebase Cloud Messaging class, FCM.h version 1.0.31
* Google's Firebase Cloud Messaging class, FCM.h version 1.0.32
*
* This library supports Espressif ESP8266 and ESP32
*
* Created June 9, 2023
* Created July 11, 2023
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2023 K. Suwatchai (Mobizt)
Expand Down
Loading

0 comments on commit 270151b

Please sign in to comment.