Firebase - response payload read timed out due to network issue or too large data size

I posted this question on github GitHub · Where software is built , but I thought it would be wise to ask it here also... Any insight is appreciated.

I feel very close to getting the ESP32 - Firebase firmware to work reliably. It seems to run fine, but will periodically have the following:

"response payload read timed out due to network issue or too large data size" The only data exchanged with the RTDB is a single integer.

Based on the lack of serial output, the WIFI connection appears to be connected and not the cause of the problem.

The best solution I found is a restart...

I don't understand all the options available. Is there something I'm missing to keep the connection to the database?

Arduino 1.8.19
Adafruit (PID 3591) HUZZAH32 – ESP32 Feather Board

2022-08-23 18:56:47 --> ets Jul 29 2019 12:21:46
2022-08-23 18:56:47 -->
2022-08-23 18:56:47 --> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
2022-08-23 18:56:47 --> configsip: 0, SPIWP:0xee
2022-08-23 18:56:47 --> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
2022-08-23 18:56:47 --> mode:DIO, clock div:1
2022-08-23 18:56:47 --> load:0x3fff0030,len:1184
2022-08-23 18:56:47 --> load:0x40078000,len:12812
2022-08-23 18:56:47 --> load:0x40080400,len:3032
2022-08-23 18:56:47 --> entry 0x400805e4
2022-08-23 18:56:47 --> Connecting to Wi-Fi...
2022-08-23 18:56:48 -->
2022-08-23 18:56:48 --> Connected with IP: 192.168.86.238
2022-08-23 18:56:48 -->
2022-08-23 18:56:48 --> Firebase Client v4.0.3
2022-08-23 18:56:48 -->
2022-08-23 18:56:49 --> Token info: type = id token, status = on request
2022-08-23 18:56:50 --> Token info: type = id token, status = ready
2022-08-23 18:56:50 --> Get integer... 0
2022-08-23 18:56:56 --> Get integer... 255 //works as expected
2022-08-23 18:57:04 --> Get integer... 128 //works as expected
2022-08-23 18:57:10 --> Get integer... 4 //works as expected
2022-08-23 18:57:18 --> Get integer... 1 //works as expected... Leave ESP32 running...
2022-08-23 19:33:53 --> Free Heap Space: 252932
2022-08-23 19:33:53 --> Get int... response payload read timed out due to network issue or too large data size

#include <WiFi.h>
#include <Firebase_ESP_Client.h>
#include "addons/TokenHelper.h"
#include "addons/RTDBHelper.h"

#define ledPin 13   // LED on Feather32
unsigned long sendDataPrevMillis = 0;
unsigned long count = 0;
int ALARM_STATUS = 0;  //integer value used to determine current alarm state

/**********************************************
 * FIREBASE SETUP
 **********************************************/
// Define Firebase objects
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig config;

/********************************************************************************************************************************************* 
 * For the following credentials, see examples/Authentications/SignInAsUser/EmailPassword/EmailPassword.ino 
 *********************************************************************************************************************************************/
#define API_KEY "AI---"
#define DATABASE_URL "ea---.firebaseio.com"
#define USER_EMAIL "ea---@gmail.com"
#define USER_PASSWORD "rd---"
#define WIFI_SSID "GO---"
#define WIFI_PASSWORD "br---"

/**********************************************
 * Firebase Variables to save database paths
 **********************************************/
String listenerPath = "/3423---/";
String dataPath = "/3423---/status";

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();

  Serial.printf("Firebase Client v%s\n\n", FIREBASE_CLIENT_VERSION);

  pinMode(ledPin, OUTPUT);    // sets the digital pin 13 as output
  digitalWrite(ledPin, HIGH); // sets the digital pin 13 on
  delay(500);
  digitalWrite(ledPin, LOW); // sets the digital pin 13 off

  /* Assign the api key (required) */
  config.api_key = API_KEY;

  /* Assign the user sign in credentials */
  auth.user.email = USER_EMAIL;
  auth.user.password = USER_PASSWORD;

  /* Assign the RTDB URL (required) */
  config.database_url = DATABASE_URL;

  /* Assign the callback function for the long running token generation task */
  config.token_status_callback = tokenStatusCallback; // see addons/TokenHelper.h

  // To connect without auth in Test Mode, see Authentications/TestMode/TestMode.ino

  //////////////////////////////////////////////////////////////////////////////////////////////
  // Please make sure the device free Heap is not lower than 80 k for ESP32 and 10 k for ESP8266,
  // otherwise the SSL connection will fail.
  //////////////////////////////////////////////////////////////////////////////////////////////

  // Limit the size of response payload to be collected in FirebaseData
  fbdo.setResponseSize(8);

  Firebase.begin(&config, &auth);

  // Comment or pass false value when WiFi reconnection will control by your code or third party library
  Firebase.reconnectWiFi(true);

  Firebase.setDoubleDigits(5);

  config.timeout.serverResponse = 10 * 1000;

  Serial.printf("Get integer... %d\n", ALARM_STATUS);
}

void loop()
{
  // Firebase.ready() should be called repeatedly to handle authentication tasks.
  if (Firebase.ready() && (millis() - sendDataPrevMillis > 500 || sendDataPrevMillis == 0))
  {
    sendDataPrevMillis = millis();

    if(Firebase.RTDB.getInt(&fbdo, dataPath)){
      ALARM_STATUS = fbdo.to<int>();
      if(ALARM_STATUS > 0){
        Serial.printf("Get integer... %d\n", ALARM_STATUS); 
        ALARM_STATUS = 0;
        Firebase.RTDB.setInt(&fbdo, dataPath, 0);
        digitalWrite(ledPin, HIGH); // sets the digital pin 13 on
        delay(5000);
        digitalWrite(ledPin, LOW); // sets the digital pin 13 off
      }
    }else{
      Serial.printf("Free Heap Space: %d\n", ESP.getFreeHeap());
      Serial.printf("Get int... %s\n", fbdo.errorReason().c_str());
      if(WiFi.status() != WL_CONNECTED){
        Serial.printf("WiFi not connected... Restarting...");
      }
      ESP.restart();
    }
  }
}

Does Firebase have a limit on the frequency of calls? Some of the IoT services will lock you out if you call them to often.

Thanks! That is a great question... If I understand it correctly I think I am subject to the following restrictions: Quotas and limits  |  Cloud Functions for Firebase. That might be a factor in what's happening...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.