Giter Club home page Giter Club logo

Comments (28)

mobizt avatar mobizt commented on May 27, 2024 1

The problem is due to Firebase server connection was reset when use ping and my library was not detect any change through WiFi core and assumed that the connection to Firebase is still alive and not need to restart server server connection.

To work around this issue at this time, please call ping before call begin stream or avoid to use ping.

This issue will be fixed in the next update soon.

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

This is because device cannot connect to internet even the WiFi was connected.

The error connection refuse is directly return by esp8266 core when connection to server was failed.

Please try the following.

  • Reset your router.
  • Connect to another WiFi hotspot.
  • Connect to soft AP created with your computer.
  • Connect to your mobile phone WiFi hotspot.

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

I have already tried connecting with my mobile phone hotspot and also tried connecting with my laptop hotspot. I cross checked and the Internet connection was properly working, actually I have also developed an app for updating values on firebase database and that app is working properly which ensures that Internet connection was proper and working.
Already tried connecting to 3 to 4 different WiFi hotspots, but the problem still retains.

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

Please try this

#include <WiFiClientSecureAxTLS.h>
using namespace axTLS;
WiFiClientSecure client;
#include <ESP8266WiFi.h>

#define FIREBASE_HOST "xxxxxxxxxxxxxxxx.firebaseio.com"
#define FIREBASE_AUTH "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.print("connecting to WiFi");
  WiFi.mode(WIFI_STA);
  WiFi.begin("SSID", "PSWxxxxxxxxx");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(200);
  }

  Serial.println("");
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  Serial.println();

  if (client.connect(FIREBASE_HOST, 443)) {

    Serial.println("Connect to Firebase OK");
    client.print("GET /number.json?auth=");
    client.print(FIREBASE_AUTH);
    client.print(" HTTP/1.1\r\n");
    client.print("Host: ");
    client.print(FIREBASE_HOST);
    client.print("\r\n");
    client.print("Connection: close\r\n\r\n");

    while (client.connected() && !client.available())
      delay(1);

    if (client.connected() && client.available())
      while (client.available())
        Serial.print((char)client.read());
  } else {
    Serial.println("Connect to Firebase failed!");
  }
}

void loop() {

}

And post the printed serial.

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

If problem still existed, please update ESP8266 Arduino Core.

From Arduino IDE, go to Tools > Board: "xxxxx" > Boards Manager.., search for esp8266 and select version 2.5.0 and install.

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

Thank you for the response.
I have already installed the correct version i.e. 2.5.0 of the ESP8266 Arduino Core library.

Here's the printed serial output.

image

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

Ok now you're ready to connect.
The library should work now.

The problem I guess is the versions of Arduino core that checked in my library are 2.4.0, 2.4.1, 2.4.2 and 2.5.0. If user installs beta or rc version or older version, some files are not included properly due to WiFi client changes since v 2.4.2 and 2.5.0.

This solved in latest commit.

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

Okay, so I have already updated the library and it worked for 2-3 times properly, but again it started to cause the same trouble. Please help to solve this issue ASAP. Here's a screenshot-

image

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

To ensure Internet connectivity I have also performed ping test.

image

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

From Arduino IDE go to menu
Tools > Debug port:, choose "Serial"
Tools > Debug Level:, choose "WIFI"
Tools > lwIP Variant:, choose "v2 Lower Memory"

Upload below sketch.

Copy all serial and post it when it shows Connect to Firebase failed!

#include <WiFiClientSecureAxTLS.h>
using namespace axTLS;
WiFiClientSecure client;
#include <ESP8266WiFi.h>


#define FIREBASE_HOST "YOUR_FIREBASE_PROJECT.firebaseio.com"
#define FIREBASE_AUTH "YOUR_FIREBASE_DATABASE_SECRET"
#define WIFI_SSID "YOUR_WIFI_AP"
#define WIFI_PASSWORD "YOUR_WIFI_PASSWORD"

unsigned long lastTime = 0;
uint32_t count = 0;

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.print("connecting to WiFi");
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(200);
  }
  Serial.println("");
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println();
}

void loop() {

  if (millis() - lastTime > 5000) {
    lastTime = millis();
    if ( WiFi.status() != WL_CONNECTED) {
      Serial.println("WIFi connection lost");
      Serial.println();
      return;
    }
    if (client.connect(FIREBASE_HOST, 443)) {
      Serial.println();
      Serial.println(">> " + String(count));
      client.print("PUT /----test----.json?auth=");
      client.print(FIREBASE_AUTH);
      client.print(" HTTP/1.1\r\n");
      client.print("Host: ");
      client.print(FIREBASE_HOST);
      client.print("\r\n");
      client.print("Connection: keep-alive\r\n");
      client.print("Keep-Alive: timeout=30, max=100\r\n");
      client.print("Content-Length: 1\r\n\r\n");
      client.print(0);
      while (client.connected() && !client.available())
        delay(1);
      if (client.connected() && client.available())
        while (client.available())
          Serial.print((char)client.read());
      Serial.println();
      Serial.println("<<");
      client.print("GET /----test----.json?auth=");
      client.print(FIREBASE_AUTH);
      client.print(" HTTP/1.1\r\n");
      client.print("Host: ");
      client.print(FIREBASE_HOST);
      client.print("\r\n");
      client.print("Connection: close\r\n\r\n");
      while (client.connected() && !client.available())
        delay(1);
      if (client.connected() && client.available())
        while (client.available())
          Serial.print((char)client.read());
      Serial.println();
    } else {
      Serial.println("Connect to Firebase failed!");
    }
  }
}

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

It's connecting to firebase successfully, the connection only fails when I turn off the mobile data from my smartphone...otherwise everything works just fine.

image

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

If this works, the library should work too, because this is the way I use in the library.

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

But still it is showing connection refused, and my Internet connection is working properly as you can see in the image. Both the device my laptop and esp8266 are connected to the same WiFi network.

image

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

Please show your serial debug and your sketch you currently used.

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

Make sure FIREBASE_HOST should not ending with any character after .com and not leading with https://
#define FIREBASE_HOST "???????.firebaseio.com"
#define FIREBASE_AUTH "????????????????"

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

And update Firebase-ESP8266 library to v 1.0.5.

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

FIREBASE_HOST and FIREBASE_AUTH are configured correctly and I have updated the Firebase-ESP8266 library recently.

Untitled

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

Please paste your code (delete your host and auth).

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

Didi you missed?

  if (!Firebase.beginStream(firebaseData, path))
  {
    Serial.println("------------------------------------");
    Serial.println("Can't begin stream connection...");
    Serial.println("REASON: " + firebaseData.errorReason());
    Serial.println("------------------------------------");
    Serial.println();
  }

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

Here's a link to my code-

https://github.com/AMAN-KHATRI/ESP8266/blob/master/Clikofy.ino

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

Okay, now I have removed ping completely from the code but the issue still persists. I really don't have any idea why this is happening, I have already tried restarting the router, connecting with my mobile phone hotspot, also tried connecting from one of my friend's mobile hotspot but yet no visible change.
Please help me to solve this issue. Thankyou.

image

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

Ok I finally fixed this issue and some bugs in mode switching. The version is still 1.0.5, please update the library and check.

from firebase-esp8266.

affibox avatar affibox commented on May 27, 2024

Ok I finally fixed this issue and some bugs in mode switching. The version is still 1.0.5, please update the library and check.

still not working on my end and I just downloaded this library on a brand new arduino IDE installation.

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

@affibox Which ESP8266 Arduino Core version you installed?

Please update ESP8266 Arduino Core to version 2.5.0 (or older 2.4.2).

@affibox and @AMAN-KHATRI
Please delete the current version of Firebase-ESP8266 from library folder.

Download and install the new one of v 1.0.5 (I just fixed the issue and update core and its header few monent ago but not change the version number)

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

Thank you so much. Now the library is working perfectly fine. One more thing, when I update the firebase using setInt or updateNode, it takes about 2 seconds to reflect changes, and at that particular time no other code is functional, everything just stops working. So, is there any faster and more efficient way to do so?
One more thing, can I use ping now in between the code?

from firebase-esp8266.

mobizt avatar mobizt commented on May 27, 2024

It depends on size of json data passed to updateNodeSilent, time for WiFi client to start new SSL connection after disconnected from stream because you use the same Firebase Data object.

Another way is use difference Firebase Data object for stream and for normal operations (get/set/push/update/delete) as in examples. But beaware of each Firebase Data Object takes about 18-20k memory.

from firebase-esp8266.

affibox avatar affibox commented on May 27, 2024

@mobizt thanks...!!!

from firebase-esp8266.

AMAN-KHATRI avatar AMAN-KHATRI commented on May 27, 2024

Thanks, @mobizt. I'll give it a try.

from firebase-esp8266.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.