Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Firebase.failed() #221

Closed
NellyWhads opened this issue Nov 3, 2016 · 43 comments
Closed

Firebase.failed() #221

NellyWhads opened this issue Nov 3, 2016 · 43 comments

Comments

@NellyWhads
Copy link

NellyWhads commented Nov 3, 2016

Hey everyone,

I seem to be having a unique error that I can't find anyone else facing. When I call Firebase.get("[path]") on a given path in my database, it returns unsuccessfully. As expected, Firebase.failed() is true, however, I can't see any output with Serial.println(Firebase.error()); (the error is empty). My database url and api key are correct as I can use them in my NodeJS project. My usage is a follows:

After my ESP12E is connected successfully to WiFi, I run Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); in my setup function.
Then, in my loop, I call FirebaseObject temp = Firebase.get("light-options"); (light-options being a path to an object in my database. Yes, I have also tried this with a single value within the object such as "light-options/red".).
This is directly followed by:
if (Firebase.failed()) { Serial.println("Firebase get failed"); Serial.println(Firebase.error()); }
At which point, the console prints the string, but no output for Firebase.error().
Also, I have ensured that the network does remain connected throughout this process.

Any thoughts? I'm not sure how to proceed.

Many thanks,
Nelly

@proppy
Copy link
Contributor

proppy commented Nov 4, 2016

can you recompile with httpclient + ssl debugging on (Tools > Debug Level) and paste the log here?

Thanks in advance.

@NellyWhads
Copy link
Author

@proppy - I seem to be having trouble finding the Debug Level settings. This may be a bit of noob question but are you speaking in the context of the Arduino IDE? I am using v1.6.11.

@proppy
Copy link
Contributor

proppy commented Nov 15, 2016

It's in Tools > Debug Level after selecting the ESP8266 module in the board manager.

@ScorpioNormal
Copy link

Hey. I have the same problem. Any operation with the firebase does not work and leads to an empty error. And before the same sketch it worked fine. Were you able to solve this problem?

@comfortme
Copy link

comfortme commented Jan 12, 2017

@ScorpioNormal same problem. none of the firebase functions works and the error is empty. also couldnt find the debug level.

edit: everything went back to normal after i switch to serial 9600

@afnalin
Copy link

afnalin commented Feb 22, 2017

I have the same problem. But I've more information: when the data at Firebase Database increases, this method ( Firebase.get([path]) ), return .success()==true and the data stored into microcontroller is "undefined". By "undefined" I mean the data is something different from database (in my case I have float values more than zero and I receive zero). When I delete child nodes at [path], the Firebase.get([path]) returns all data correctly. I thing this is some problem related to buffer sizes.
Using the ArduinoJson Assistant (https://bblanchon.github.io/ArduinoJson/assistant/), my data that don't arrive correctly have 799 bytes (size for ESP8266). When I reduce my data to 599 bytes, the data arrive correctly. I have only 2 levels of nested objects (path/level1/level2). I don't know where is the problem, but it seems buffer related and Firebase.success() is true when this problem occours.

@NellyWhads
Copy link
Author

@afnalin can you share your MCU and your logging steps? I can try this out on my ESP and see if the buffer size is device specific

@istudiomobile
Copy link

Any progress on this? Same problem, sketch isn't talking to Firebase, no error messages. I'm available for tests.

@sindiddle
Copy link

sindiddle commented Jul 13, 2017

any update?still can't figure it out what's wrong with my sketch. already tried many tutorials, none of it able to talk to Firebase

[update] solved my problem by erasing the "https://" and "/" (at the end of the sentence) when defining the FIREBASE_HOST

@lanhnguyen2010
Copy link

I get the same problem with @afnalin.

When I try to get FirebaseOject from the root, it returns {} empty Json. I try to specify the path to a child node and it works.

Also check with https://bblanchon.github.io/ArduinoJson/assistant/. The FirebaseObject only works with Json smaller than 772 bytes. I use a NodeMCU 1.0.

For more detail. Below is my data in Firebase database.

Data works (772 bytes). That means I can get FirebaseObject in ESP8266.

{"description":"bxhchc","deviceType":1,"lastConnectedTime":"Tue Aug 01 22:55:40 2017\n","name":"trang1","reset":false,"settings":{"4":{"forceTurnOn":false,"timeSettingsList":[{"days":[0,2,4,7],"end":{"hour":23,"minute":18},"start":{"hour":1,"minute":3}},{"days":[1],"end":{"hour":2}}]}},"uid":"2itLuPyoaXcnrZyd2QkbsxJaAPm1","version":1}

I only add a new child node ("start" :{"hour":2}} ) to make Data become 825 bytes and It went away. Returned FirebaseObject in ESP8266 now is Empty.

{"description":"bxhchc","deviceType":1,"lastConnectedTime":"Tue Aug 01 22:55:40 2017\n","name":"trang1","reset":false,"settings":{"4":{"forceTurnOn":false,"timeSettingsList":[{"days":[0,2,4,7],"end":{"hour":23,"minute":18},"start":{"hour":1,"minute":3}},{"days":[1],"end":{"hour":2}, "start" :{"hour":2}}]}},"uid":"2itLuPyoaXcnrZyd2QkbsxJaAPm1","version":1}

Thanks a lot.

@ghost
Copy link

ghost commented Nov 26, 2017

The problem is when you are trying to access to your FirebaseDatabase, you need to:

#define FIREBASE_HOST "yourproject.firebaseio.com/"

You need to write '/' at the end because you are going to access to:

yourproject.firebaseio.comdatabase

Insted of

yourproject.firebaseio.com/database

It is importat to check if you have a '/' while calling the path.

@harshgar
Copy link

Hey everyone m having the same issue with my esp. I was using the demo code that comes with esp package to upload data to my firebase and its not able to do so. It's showing error "setting /number failed:". So far I have tried everything i could think of I have double checked my secret database key and hostname (tried it with and without that "/" at the end), changed upload speed to 9600 and even tried using older version of ide i.e "1.6.9". Still no luck. Any help would be appreciated.
Thanks!

@Jackfr0zt
Copy link

@harshgar did you fix that already? cause we have the same problem.. help me plss

@harshgar
Copy link

@Jackfr0zt Yes I solved it. I used IDE version "1.6.9" plus I removed the older version of the firebase library and re-downloaded and re-installed it that solved my issue. There was an issue with the push function of that library that was resolved in the later version of the library so u need to download the latest version of firebase master library.
Link for the same- https://github.com/firebase/firebase-arduino

@baudcode
Copy link

@lanhnguyen2010 the returned object is empty because FIREBASE_JSONBUFFER_SIZE in FirebaseObject.h is set too low. Replace the line
#define FIREBASE_JSONBUFFER_SIZE JSON_OBJECT_SIZE(32)
with e.g.
#define FIREBASE_JSONBUFFER_SIZE JSON_OBJECT_SIZE(128)

@lenguyenvu007
Copy link

@baudcode : it should be considered more when you increase to JSON_OBJECT_SIZE(128)
The ESP8266 might become wdt,
because over memory at: StaticJsonBuffer<FIREBASE_JSONBUFFER_SIZE> buffer_;

Inside library file: FirebaseObject.h
Please check it and confirm again!

@proppy
Copy link
Contributor

proppy commented Jun 15, 2018

Sorry for the late reply, you should be able to define JSON_OBJECT_SIZE in your own sketch.

Filed #349 to track improving error reporting.

@proppy proppy closed this as completed Jun 15, 2018
@mesut25
Copy link

mesut25 commented Jul 5, 2018

Firebase.setInt("MES", MES);
A0 RUN bağlantı ok

val1=Firebase.getString("S1").toInt();
sadece bu satır sonra hata veriyor
hata masajı yok
[email protected]

#define Relay1 12 //D6
#define DEBUG true
int val1;
void setup()
{
Serial.begin(115200);
EEPROM.begin(512);
pinMode(Relay1,OUTPUT);
digitalWrite(Relay1,LOW);
WiFi.begin(WIFI_SSID,WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status()!=WL_CONNECTED){
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected:");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
Firebase.setInt("S1",0);
}
void firebasereconnect()
{
Serial.println("Trying to reconnect");
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
void loop()
{
int MES = analogRead(A0);
Firebase.setInt("MES", MES);
val1=Firebase.getString("S1").toInt();
switch (val1) {
case 0:

break;

case 1:
digitalWrite(Relay1,HIGH);
Serial.println("light 1 ON");

break;
 case 2:

digitalWrite(Relay1,LOW);

Serial.println("light 1 OFF");

break;

}
}

@kotl
Copy link
Collaborator

kotl commented Jul 5, 2018

@proppy - in Arduino IDE, anything you define in sketch does not get propagated into library code. So defining it won't work unless you modify header of the library itself. We can, however, modify library to have JSON memory size setting.

@mesut25
Copy link

mesut25 commented Jul 5, 2018

FirebaseObject.h is set too low. Replace the line

#define FIREBASE_JSONBUFFER_SIZE JSON_OBJECT_SIZE(128)
basit bir örnek....
resimli anlatım olabilir....
basit bir çıkış mantıgı (val1=Firebase.getString("S1").toInt();) hata için

firebase için 12e modül output için modify library ????

@proppy
Copy link
Contributor

proppy commented Jul 5, 2018

@kotl really? It should work if you redefine it before the #include?

@mesut25
Copy link

mesut25 commented Jul 5, 2018

int LDR = A0;
#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include<FirebaseArduino.h>
#define FIREBASE_HOST "esp8266m.firebaseio.com"
#define FIREBASE_AUTH "zmaE1BTaDxMlk45tYycvDIdaIdf328GKa2eDaHQx"
#define WIFI_SSID "18F2550"
#define WIFI_PASSWORD "mesutaslan1"
#define Relay1 12 //D6
#define DEBUG true
int val1;
FirebaseArduino FirebaseStream;
void setup()
{

pinMode(Relay1,OUTPUT);

Serial.begin(9600);

// connect to wifi.
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());

Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
FirebaseStream.begin(FIREBASE_HOST, FIREBASE_AUTH);
FirebaseStream.stream("/data");
}

int n = 0;
void loop() {
// Serial.println("loop");
//Firebase.setInt("S1", n++);
if (Firebase.failed()) {
Serial.println(Firebase.error());
}
int data = Firebase.getInt("S1");
int MES = analogRead(A0);
Firebase.setInt("MES", MES);

switch (data) {
case 0:

break;

case 1:
digitalWrite(Relay1,HIGH);
Serial.println("light 1 ON");

break;
 case 2:

digitalWrite(Relay1,LOW);

Serial.println("light 1 OFF");

break;

if (Firebase.failed()) {
Serial.println(Firebase.error());
}
Serial.print("data: ");
Serial.println(data);
Serial.print("heap: ");
if (FirebaseStream.available()) {
FirebaseObject event = FirebaseStream.readEvent();
Serial.print("event: ");
Serial.println(event.getString("event"));
Serial.print("path: ");
Serial.println(event.getString("path"));
Serial.print("data: ");
Serial.println(event.getInt("data"));
}
Serial.println(ESP.getFreeHeap());
delay(1000);
}
}
ŞİMDİ TEST....
SADECE OUTPUT ÇIKIŞ HATA VERİYOR (int data = Firebase.getInt("S1");)
SATIR 10 dakika sonra çalışmıyorrr
neden????

@mesut25
Copy link

mesut25 commented Jul 5, 2018

yeniden library yazmalı ..
12e output için

@kotl
Copy link
Collaborator

kotl commented Jul 6, 2018

@proppy it does not redefine it in the library:
The Arduino IDE compiles libraries individually so you would need to pass the define as a -D option during the compile. The Arduino IDE does not currently provide a facility for you to easily do that. Arduino 1.5 provides some functionality via the boards.txt system but this probably will not provide the flexibility you need.

Quoted from https://stackoverflow.com/questions/14418936/overriding-define-in-libraries

@proppy
Copy link
Contributor

proppy commented Jul 6, 2018

@kotl I think it might work in ArduinoJson case, since it's an header only library.
Maybe we could turn FirebaseArduino into a header library to do the same?

#353 could help as we could remove most of the code and only keep FirebaseArduino.h

@mesut25
Copy link

mesut25 commented Jul 6, 2018

gelen json sayıları işlem sonrası buffer temizlemek nasıl...
benim program hafıza taşınca çöküyor gibi...
StaticJsonBuffer.clear () # 72 hafızaları nasıl temizlerim...

hafıza temizlemek ...nasıl yapılır..

@rishini
Copy link

rishini commented Mar 4, 2019

hey all,
It's urgent plz help.
I also have the same problem. I was using the demo code that comes with esp package to upload data to my firebase. It's showing error "setting /number failed:". I am using the new arduinojson library. Tried by adding the secrets to FIREBASE_AUTH and also tried by removing it. But none of it didn't work. If you can help it would be appreciated.
Thank you!

@falery
Copy link

falery commented Mar 6, 2019

@rishini same with me, I don't can connecting my firebase to esp..

@preksha02
Copy link

same issue! i use esp8266MOD ,everything is perfectly, but nothing is shown on firebase. Please Help!

@Chriton
Copy link

Chriton commented Mar 14, 2019

@rishini
Copy link

rishini commented Mar 15, 2019

Thanks, @Chriton but that's also not working. Do you know any different ways to solve this problem?

@Chriton
Copy link

Chriton commented Mar 15, 2019

@rishini don't know any other, that worked for me

@rishini
Copy link

rishini commented Mar 15, 2019

Please tell me @Chriton when I am adding the zip files that you mentioned do I have to remove any libraries?

@Chriton
Copy link

Chriton commented Mar 15, 2019

@rishini just follow the steps in https://github.com/Chriton/Firebase-Arduino/tree/master/Arduino%20Project#troubleshooting :

  • first check the new Firebase fingerprint here Server Fingerprints. Copy your database address in there (eg. mydatabase.firebaseio.com) and click on Fingerprint Site. For me at this moment it shows: 6F:D0:9A:52:C0:E9:E4:CD:A0:D3:02:A4:B7:A1:92:38:2D:CA:2F:26
  • Do not just copy this one, maybe it has changed again, so just verify it yourself.
  • remove the firebase-arduino library added initially like shown in the "Removing an arduino library" section.
  • download a firebase-arduino zip release from the repository, then extract all the files into a folder of your choice and replace the old fingerprint which can be found in the extracted files -> src/FirebaseHttpClient.h -> kFirebaseFingerprint
  • after you add the new fingerprint into FirebaseHttpClient.h, save it and put all the files back into a zip file and reimport the library like shown in the "Arduino IDE Setup & adding libraries" section.
  • restart Arduino IDE and recompile your sketch.

@Chriton
Copy link

Chriton commented Mar 15, 2019

@rishini also check this out: cd5681f#commitcomment-32762792

@rishini
Copy link

rishini commented Mar 16, 2019

Thank you very much @Chriton you saved my project.
It's about the fingerprint. The latest fingerprint is "E2 34 53 7A 1E D9 7D B8 C5 02 36 0D B2 77 9E 5E 0F 32 71 17" Make sure to put this" ; "after the fingerprint. And remove the key also.
Guys, @preksha02 @falery try that. It may be work for you also.
Thanks.

@preksha02
Copy link

preksha02 commented Mar 19, 2019 via email

@rishini
Copy link

rishini commented Mar 19, 2019

@preksha02 Make sure to close the whole Arduino IDE after adding the new fingerprint. Then open it and try the code.

@preksha02
Copy link

preksha02 commented Mar 19, 2019 via email

@preksha02
Copy link

preksha02 commented Mar 20, 2019 via email

@theKlinc
Copy link

@Chriton Thank you! Your solution worked for me.

@IsuruMS
Copy link

IsuruMS commented Sep 5, 2020

@Chriton Thank You for the answer. This worked.

@decoded-cipher
Copy link

@rishini just follow the steps in https://github.com/Chriton/Firebase-Arduino/tree/master/Arduino%20Project#troubleshooting :

  • first check the new Firebase fingerprint here Server Fingerprints. Copy your database address in there (eg. mydatabase.firebaseio.com) and click on Fingerprint Site. For me at this moment it shows: 6F:D0:9A:52:C0:E9:E4:CD:A0:D3:02:A4:B7:A1:92:38:2D:CA:2F:26
  • Do not just copy this one, maybe it has changed again, so just verify it yourself.
  • remove the firebase-arduino library added initially like shown in the "Removing an arduino library" section.
  • download a firebase-arduino zip release from the repository, then extract all the files into a folder of your choice and replace the old fingerprint which can be found in the extracted files -> src/FirebaseHttpClient.h -> kFirebaseFingerprint
  • after you add the new fingerprint into FirebaseHttpClient.h, save it and put all the files back into a zip file and reimport the library like shown in the "Arduino IDE Setup & adding libraries" section.
  • restart Arduino IDE and recompile your sketch.

@Chriton - This method really helps me solve the issue...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests