Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has anyone had problems with your Nodemcu and Firebase connection? #369

Open
filactito opened this issue Aug 2, 2018 · 131 comments
Open

Has anyone had problems with your Nodemcu and Firebase connection? #369

filactito opened this issue Aug 2, 2018 · 131 comments
Labels

Comments

@filactito
Copy link

Hi.
Has anyone had problems with your Nodemcu and Firebase connection? everything worked correctly until today.

Is someone having this problem?

@Daniel-Moraes
Copy link

Yes, I cant connect..

@adamrabbani
Copy link

firebase has new fingerprint =>
6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26

just edit this file, FirebaseHttpClient.h

@filactito
Copy link
Author

filactito commented Aug 2, 2018

Works correctly !! Thank you @adamrabbani :)

@Daniel-Moraes
Copy link

Thank you so much @adamrabbani !!!!!!!!!!!!!!!!!!!!

@ExploreLab
Copy link

@adamrabbani
Thank you so much

@HugoLimon
Copy link

Damm!! Thank you a lot bro

@mobizt
Copy link

mobizt commented Aug 3, 2018

This is my own solutions to handle the fingerprint changes
Solution 1

  1. Create php file on web server that will provide firebaseio.com fingerprint via get request which the host to get fingerprint is test.firebaseio.com

  2. Modify FirebaseHttpClient_Esp8266.cpp
    from line no. 22

 public:
  FirebaseHttpClientEsp8266() {}

to

public:
 String fingerprint;
  FirebaseHttpClientEsp8266() {
	http_.begin("http://{YOUR WEB SERVER}.com/fingerprint.php?host=test.firebaseio.com");
	int httpCode = http_.GET();
	if (httpCode == HTTP_CODE_OK)
		fingerprint = http_.getString();
	http_.end();
  }

and from line no. 46

void begin(const std::string& url) override {
    http_.begin(url.c_str(), kFirebaseFingerprint);
  }

  void begin(const std::string& host, const std::string& path) override {
    http_.begin(host.c_str(), kFirebasePort, path.c_str(), kFirebaseFingerprint);
  }

to

 void begin(const std::string& url) override {
    http_.begin(url.c_str(), fingerprint);
  }

  void begin(const std::string& host, const std::string& path) override {
    http_.begin(host.c_str(), kFirebasePort, path.c_str(), fingerprint);
  }

This is fingerprint.php file

<?php
	
# PHP SSL Fingerprint Checker written by W. Al Maawali  
# (c) 2013 Founder of Eagle Eye Digital Solutions
# http://www.digi77.com
# http://www.om77.net
# script starts here:
# Usage: http://www.yourdomain.com/sslf.php
# Example: http://www.digi77.com/software/fingerprint/fp-public.php?hosts=www.facebook.com

//avoid timeouts
set_time_limit(0);

//For String variable use prevent sql injections
function StringInputCleaner($data)
{
	$data = trim($data); 
	$data = stripslashes($data); 
	$data=(filter_var($data, FILTER_SANITIZE_STRING));
	return $data;
}	

function getSllCertificate($hostname, $port = 443)
{
	$context = stream_context_create(array("ssl" => array("capture_peer_cert" => true)));
	$socket = @stream_socket_client("ssl://$hostname:$port", $errno, $errstr, ini_get("default_socket_timeout"), STREAM_CLIENT_CONNECT, $context);
 
	if(!$socket)
		return array("md5" => "error", "sha1" => "error");
 
	$contextdata = stream_context_get_params($socket);
	$contextparams = $contextdata['options']['ssl']['peer_certificate'];
 
	fclose($socket);
 
	openssl_x509_export($contextparams, $cert, true);
	openssl_x509_free($contextparams);
 
	$repl = array("\r", "\n", "-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----");
	$repw = array("", "", "", "");
 
	$cert = str_replace($repl, $repw, $cert);
 
	$decoded = base64_decode($cert);
	$fingerprints = array(
		"md5" => md5($decoded),
		"sha1" => sha1($decoded),
	);
	
	
	return $fingerprints ;
}

$host=$_GET['host'];
//clean string safer coding
$host=StringInputCleaner($host);
$port=443;
$hashes = getSllCertificate($host, $port);

echo($hashes['sha1']);

?>

Solution 2

Bypass the finger print verification in WiFiClientSecure.cpp in C:\Users{YOUR NAME}\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\ESP8266WiFi\src

from line no. 630 to

bool WiFiClientSecure::verify(const char* fp, const char* domain_name)
{
return trure;

@turbo105
Copy link

turbo105 commented Aug 3, 2018

@adamrabbani GOD BLESS!!!!!! We have a project due on monday (3 days from this post) and randomly our firebase started failing. God bless you, God bless your family, god bless your ancestors.

@stlcool
Copy link

stlcool commented Aug 3, 2018

@adamrabbani jesus christ god bless indeed. That was really scary. Whats the scoop on this?

@arkochatterjee
Copy link

@adamrabbani
I have changed the fingerprint, but it's still not working.
Did I miss anything?

image

@JaysArtworks
Copy link

@arkochatterjee I've the same issue...but the fingerprint for me is already correct.

@santoshn547
Copy link

I have the same issue. I changed the fingerprint, but its still not working, It begins connection and starts streaming.
Then
Unable to get/read Data from firebase and firebase Stream is failing.
Tried updating ArduinoJson as well no use.

Does Anyone know the solution ?

@hammad42
Copy link

hammad42 commented Aug 7, 2018

hi @adamrabbani hope you doing well can you plz tell that where i found firebasehttp.client.h. your answer would be highly appreciated

@santoshn547
Copy link

@hammad42
You can find that file inside libraries folder of Arduino.
Libraries-> firebase-arduino-master -> src-> firebasehttp.client.h

@hammad42
Copy link

hammad42 commented Aug 7, 2018

thankyou @santoshn547 but finger print is already same as above which is wrote by @adamrabbani

@hammad42
Copy link

hammad42 commented Aug 7, 2018

@santoshn547 if you found any success plz share it with me i have submit my fyp project and i stuck on this my code was works fine then this shit happens..

@hammad42
Copy link

hammad42 commented Aug 7, 2018

@JaysArtwork did you find any success..

@santoshn547
Copy link

santoshn547 commented Aug 7, 2018

@hammad42
Even I haven't found any solution !

@JaysArtworks
Copy link

@hammad42 I did not find any solution...damn

@hammad42
Copy link

hammad42 commented Aug 8, 2018

Ok @JaysArtworks@Santoshn547 do one thing download old library and go to firebase http client.h and edit finger print as above adamrabbani shows

@kimleng-ly
Copy link

@adamrabbani @ Thank you very much my friend. You save my project. I have try many weeks ago. Now it work fine. Many many thank.

@kimleng-ly
Copy link

@adamrabbani @ how can we know that firebase change that? If later firebase change again, where can we find it?

@mobizt
Copy link

mobizt commented Aug 9, 2018

@kimleng-ly you can check fingerprint through this site https://www.grc.com/fingerprints.htm?domain=yourdatabase.firebaseio.com

For test you can use https://www.grc.com/fingerprints.htm?domain=test.firebaseio.com.

If you read my post above, solution 1 (if you have PHP skill) is for automatically update fingerprint when your device start to connect to firebase.

In case of you want to bypass fingerprint checking please see solution 2 of my previous post.

@kimleng-ly
Copy link

@mobizt Many thank my friend. You save a lot time for me to search it. Thank.

@AlexPivo
Copy link

AlexPivo commented Aug 10, 2018

Good day, replaced the code, the application runs 2-3 minutes, after writing: DB failed. What is the solution ?

part_progr

db failed


6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26

file FirebaseHttpClient.h edited

@mobizt
Copy link

mobizt commented Aug 10, 2018

@AlexPivo If you want to by pass fingerprint verification, write
"return true;" first inside the function and no need to edit finger print in FirebaseHttpClient.h.

bool WiFiClientSecure::verify(const char* fp, const char* domain_name)
{
    return true; //<--- here

    if (!_ssl) {
        return false;
    }

@AlexPivo
Copy link

Thanks, it's working. Works 2-3 minutes, then error. Crash controller (freezes controller ) and start working again in 2-3 minutes.

p.s. Error not writes: DB failed

@pcliu624
Copy link

the library should be inside the Document/Arduino/libraries, not the program files,
it should be the same file of your project saved in.
This works for me.

@proppy
Copy link
Contributor

proppy commented Aug 16, 2018

Can you confirm that was fixed with #368 ?

@alvaroaguero55
Copy link

@mobizt Im using your library. At first use it connects fine but is internet connection goes down (ie WiFi keeps but Internet is offline for some time) then doesnt autoconnect again when internet connection goes online again. How can I fix it?

@mobizt
Copy link

mobizt commented May 16, 2019

@alvaroaguero55 Are you use the latest version? Please update and if problem still exists, please open the issue on my GitHub and share your more information for sketch and kind of router or AP.

@kimleng-ly
Copy link

@mobizt Could you send me the link of new last updated library? Thank.

@mobizt
Copy link

mobizt commented May 18, 2019

@kimleng-ly my library? please visit my GitHub, you'll see the repos.

@Alpha-1729
Copy link

https://www.hackanons.com/2018/02/iot-with-firebase-connecting-arduino.html

use the lower version of the arduino ide described in the link ....and use Arduinojson ver 5.13.5
all erros will be solved...

use wise uninstaller for removing all files of the latest version of the arduino............click on force uninstall

then restart the system....

install arduino ver 1.6.9

install 2.4.0 esp8266 board manager
install 5.13.5 Arduinojson
install firebase arduino described in the link...

change firebase url,key,ssid,password in the sample code in the link

upload the script all will be fine

@Alpha-1729
Copy link

Alpha-1729 commented May 21, 2019 via email

@Raj7912
Copy link

Raj7912 commented Mar 30, 2020

@adamrabbani
I have changed the fingerprint, but it's still not working.
Did I miss anything?

image

You didn't miss anything. actually your code cant make changes on firebase database due to internet connection that's why you're getting problem.

@Alpha-1729
Copy link

use arduino json 5.13.5
use esp8266 versioin 2.60
use latest firebase arduino library from github
use arduino ide latest version
it will work

@ghost
Copy link

ghost commented May 2, 2020

use arduino json 5.13.5
use esp8266 versioin 2.60
use latest firebase arduino library from github
use arduino ide latest version
it will work

bro can you please provide me the link of latest firebase arduino library?

@Alpha-1729
Copy link

@Alpha-1729
Copy link

if you have any error, provide your code.

@ghost
Copy link

ghost commented May 4, 2020

if you have any error, provide your code.

actually i am trying to read data from rfid reader MFRC522 which is connected to the nodemcu esp8266 module, and then i am trying to send that data to the firebase real time database, code gets uploaded no error found, but data is not updating on the firebase real time database, i did all what you said above, arduino json 5.13.5, esp8266 board version 2.60, latest library of firebase arduino and latest arduino ide version

@Alpha-1729
Copy link

try this code.......
it this code works....
change your code accordingly.....

#include <ESP8266WiFi.h>                                                    // esp8266 library
#include <FirebaseArduino.h>                    // firebase library
// dont add / at the end.                             
#define FIREBASE_HOST "something.firebaseio.com"                         // the project name address from firebase id

#define WIFI_SSID "ssid_name"                                             // input your home or public wifi name 
#define WIFI_PASSWORD "aaaaaaaa"                                    //password of wifi ssid
                                                     
void setup() {
  Serial.begin(9600);
  delay(1000);                
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);                                     //try to connect with wifi
  Serial.print("Connecting to ");
  Serial.print(WIFI_SSID);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("Connected to ");
  Serial.println(WIFI_SSID);
  Serial.print("IP Address is : ");
  Serial.println(WiFi.localIP());                                            //print local IP address
  Firebase.begin(FIREBASE_HOST);                              // connect to firebase                                                              //Start reading dht sensor
}

void loop() { 
  
  String my_msg ="hello-world";                       
  Firebase.pushString("/trial/messgae", my_msg);                                  //setup path and send readings
  delay(1000);
}

also change database rule like this

{
"rules": {
".read": "true",
".write": "true"
}
}

@Alpha-1729
Copy link

change the FIREBASE_HOST with your firebase url ... without http://

@ghost
Copy link

ghost commented May 5, 2020

@Alpha-1729 Thanks mate, it worked (y) thanks a lot for your help
firebase library, i took latest from you,
board version, esp8266 2.6.0,
arduino json, 5.13.5,
arduino ide, 1.8.12

@Alpha-1729
Copy link

@Alpha-1729 Thanks mate, it worked (y) thanks a lot for your help
firebase library, i took latest from you,
board version, esp8266 2.6.0,
arduino json, 5.13.5,
arduino ide, 1.8.12

whats wrong with your setup

@Fayzul-csejnu
Copy link

Fayzul-csejnu commented Sep 18, 2020

What's wrong on my code?I am trying to read data from pulse sensor(gy max30100) and send it to firebase using Node mcu(ESP-8266) . But it doesn't function properly. Here is my code. It will be very helpful to me if anyone can fix my issue. Thanks in advance.

#include <Arduino.h>
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include "ESP8266WebServer.h"
#include <FirebaseArduino.h>

#define REPORTING_PERIOD_MS 500

#define FIREBASE_HOST ""
#define FIREBASE_AUTH ""

#define WIFI_SSID ""
#define WIFI_PASSWORD ""

PulseOximeter pox;

uint32_t tsLastReport = 0;
volatile boolean heartBeatDetected = false;

void onBeatDetected()
{
heartBeatDetected = true;
Serial.println("Beat!");
}

void setup()
{
Serial.begin(115200);

// 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 with IP: ");
Serial.println(WiFi.localIP());

// Begin connection to Firebase
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);

// Show the last error
if (Firebase.failed()) {
    Serial.print("setting /message failed:");
    Serial.println(Firebase.error());
    ESP.reset();
}

// Initialize the PulseOximeter instance and register a beat-detected callback
pox.begin();
pox.setOnBeatDetectedCallback(onBeatDetected);

}

void loop()
{
pox.update();

if (millis() - tsLastReport > REPORTING_PERIOD_MS) {

    float bpm = pox.getHeartRate();
    float spO2 = pox.getSpO2();

    Serial.print("Heart rate:");
    Serial.print(bpm);
    Serial.print("bpm / SpO2:");
    Serial.print(spO2);
    Serial.println("%");

    tsLastReport = millis();

    // If the values are valid and heart beat detected, publish to Firebase
    if (heartBeatDetected && bpm != 0) {
        Firebase.setFloat("sensor/HeartBeat", bpm);
        Firebase.setInt("sensor/SpO2", spO2);
    }
}

}

@Alpha-1729
Copy link

Alpha-1729 commented Sep 20, 2020

Is this the value in your firebase.

{'sensor': {'HeartBeat': 9.218459, 'SpO2': 0}}

Please Note this point:

  • Dont add your actual crendential in the code.

Is this printing the actual value

Serial.print("Heart rate:");
    Serial.print(bpm);
    Serial.print("bpm / SpO2:");
    Serial.print(spO2);
    Serial.println("%");

Covert float to string and upload to firebase.

Try first with the sample code given above by me.

String my_msg ="hello-world";                       
  Firebase.pushString("/trial/messgae", my_msg);                                  //setup path and send readings
  delay(1000);

@Fayzul-csejnu
Copy link

Fayzul-csejnu commented Sep 20, 2020

Sorry, I have filed to describe my issues in my previous comment.

The following code prints actual values when no firebase credentials are included.

Serial.print("Heart rate:");
Serial.print(bpm);
Serial.print("bpm / SpO2:");
Serial.print(spO2);
Serial.println("%");

But the problem arises when I add firebase setup on my code. Even It doesn't print any true value on my serial Monitor.

Furthermore, the serial monitor prints a few random values on the serial monitor, and it "successfully" sends the data to the firebase.

The following link also describes the same problem.

Click Here

Please help me if you can.
Thanks in advance.

@Alpha-1729
Copy link

try this code.......
it this code works....
change your code accordingly.....

#include <ESP8266WiFi.h>                                                    // esp8266 library
#include <FirebaseArduino.h>                    // firebase library
// dont add / at the end.                             
#define FIREBASE_HOST "something.firebaseio.com"                         // the project name address from firebase id

#define WIFI_SSID "ssid_name"                                             // input your home or public wifi name 
#define WIFI_PASSWORD "aaaaaaaa"                                    //password of wifi ssid
                                                     
void setup() {
  Serial.begin(9600);
  delay(1000);                
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);                                     //try to connect with wifi
  Serial.print("Connecting to ");
  Serial.print(WIFI_SSID);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("Connected to ");
  Serial.println(WIFI_SSID);
  Serial.print("IP Address is : ");
  Serial.println(WiFi.localIP());                                            //print local IP address
  Firebase.begin(FIREBASE_HOST);                              // connect to firebase                                                              //Start reading dht sensor
}

void loop() { 
  
  String my_msg ="hello-world";                       
  Firebase.pushString("/trial/messgae", my_msg);                                  //setup path and send readings
  delay(1000);
}

also change database rule like this

{
"rules": {
".read": "true",
".write": "true"
}
}

@fredshutdap
Copy link

cant

try this code.......
it this code works....
change your code accordingly.....

#include <ESP8266WiFi.h>                                                    // esp8266 library
#include <FirebaseArduino.h>                    // firebase library
// dont add / at the end.                             
#define FIREBASE_HOST "something.firebaseio.com"                         // the project name address from firebase id

#define WIFI_SSID "ssid_name"                                             // input your home or public wifi name 
#define WIFI_PASSWORD "aaaaaaaa"                                    //password of wifi ssid
                                                     
void setup() {
  Serial.begin(9600);
  delay(1000);                
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);                                     //try to connect with wifi
  Serial.print("Connecting to ");
  Serial.print(WIFI_SSID);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("Connected to ");
  Serial.println(WIFI_SSID);
  Serial.print("IP Address is : ");
  Serial.println(WiFi.localIP());                                            //print local IP address
  Firebase.begin(FIREBASE_HOST);                              // connect to firebase                                                              //Start reading dht sensor
}

void loop() { 
  
  String my_msg ="hello-world";                       
  Firebase.pushString("/trial/messgae", my_msg);                                  //setup path and send readings
  delay(1000);
}

also change database rule like this

{
"rules": {
".read": "true",
".write": "true"
}
}

still cant connect to firebase

@Raj7912
Copy link

Raj7912 commented Nov 1, 2020

Firebase.pushString("/trial/messgae", my_msg);

//Chenge this line By setup path and send readings

@EngrMMS
Copy link

EngrMMS commented Aug 3, 2021

Hello everyone!

If anyone is still facing this issue of firebase not connecting to ESP8266, here is a peace of advice for you:
Install latest Arduino IDE
Install latest Firebase Library from this link:
Install older version of nodemcu board i.e. v2.5.0
Install Arduino.json library v5
Install Firebasejson library
Install esp8266wifi library

After installation and including above libraries, just go to this Link: and enter test.firebaseio.com in URL section and then click Fingerprint site button to generate the new Fingerprint code for you.
Then copy the fingerprint code and paste it in FirebaseHttpClient.h file available on this route: Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient.h

This is definitely gonna work, try it!

@Finthugo
Copy link

Finthugo commented Sep 2, 2021

@AlexPivo If you want to by pass fingerprint verification, write
"return true;" first inside the function and no need to edit finger print in FirebaseHttpClient.h.

bool WiFiClientSecure::verify(const char* fp, const char* domain_name)
{
    return true; //<--- here

    if (!_ssl) {
        return false;
    }

First of all thank you for your amazing library Mobizt.
Is the fingerprint bypass procedure still required in your new esp8266 and esp32 client library ??

@Finthugo
Copy link

Finthugo commented Sep 2, 2021

@mobizt
First of all thank you for your amazing library Mobizt.
Is the fingerprint bypass procedure still required in your new esp8266 and esp32 client library ??
(sorry forgot to tag you in the last post)

@mobizt
Copy link

mobizt commented Sep 2, 2021

@Finthugo

The fingerprint verification is not secure for server verification, use Root CA certificate for server verification is secured.

My library allows Root CA certificate verification only for secure mode connection using WiFiClientSecure class to make own secure TCP client then nothing is related to the fingerprint data that used in ESP8266HTTPClient class that used by other Firebase library.

And library also support insecure mode (no Root CA certificate verification).

@Finthugo
Copy link

Finthugo commented Sep 2, 2021

@Finthugo

The fingerprint verification is not secure for server verification, use Root CA certificate for server verification is secured.

My library allows Root CA certificate verification only for secure mode connection using WiFiClientSecure class to make own secure TCP client then nothing is related to the fingerprint data that used in ESP8266HTTPClient class that used by other Firebase library.

And library also support insecure mode (no Root CA certificate verification).

Thank you so much for your fast reply!
Just to be sure, so I don't need to worry about any kind of fingerprint changes of firebase right ?

@mobizt
Copy link

mobizt commented Sep 2, 2021

@Finthugo

I said "nothing is related to the fingerprint data" is clear already.

@vilelalabs
Copy link

this answer in this thread was what worked for me

To get the updated Fingerprint using the given links.

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

No branches or pull requests