Coder Social home page Coder Social logo

Comments (8)

mobizt avatar mobizt commented on May 24, 2024

You're trying to use your device ESP8266 as server while connected to internet.

Which you need to set the WiFi mode to AP_STA to connect to both client as server and Firebase server via internet as client.

You need to start with

WiFi.mode(WIFI_AP_STA);

Then connect to WiFi with

WiFi.begin("WiFi_SSID", "WiFi_PSW");

Then set your device as AP

WiFi.softAP("Your_AP_Name", "Your_AP_PSW");

You may face some unreliable issues which you can search from google or Github about WiFi in WiFi_AP_STA mode.

The following blocking code from handle client data will block the Firebase stream connection too as it runs in the loop.

if (server.hasClient())
  {
    client = server.available();
  }
  if (client && client.connected()) {
    if (client.available()) {
      String readString = "";
      while (client.available())
      {
        char c = ((char)client.read());
        readString += c;
      }
      val = readString.toInt();
    }
  }

I'm not recommend to use device as server and client at the same time because the library need to connect to internet and assume that your device was well configured and internet ready.

When some blocking operation that cases the STA mode connection problem occurred, library will report the error based on WiFi client status after trying to reconnect the WiFi or timed out when trying to connect to server.

from firebase-esp8266.

DavidSAlexander avatar DavidSAlexander commented on May 24, 2024

You're trying to use your device ESP8266 as server while connected to internet.

Which you need to set the WiFi mode to AP_STA to connect to both client as server and Firebase server via internet as client.

You need to start with

WiFi.mode(WIFI_AP_STA);

Then connect to WiFi with

WiFi.begin("WiFi_SSID", "WiFi_PSW");

Then set your device as AP

WiFi.softAP("Your_AP_Name", "Your_AP_PSW");

You may face some unreliable issues which you can search from google or Github about WiFi in WiFi_AP_STA mode.

The following blocking code from handle client data will block the Firebase stream connection too as it runs in the loop.

if (server.hasClient())
  {
    client = server.available();
  }
  if (client && client.connected()) {
    if (client.available()) {
      String readString = "";
      while (client.available())
      {
        char c = ((char)client.read());
        readString += c;
      }
      val = readString.toInt();
    }
  }

I'm not recommend to use device as server and client at the same time because the library need to connect to internet and assume that your device was well configured and internet ready.

When some blocking operation that cases the STA mode connection problem occurred, library will report the error based on WiFi client status after trying to reconnect the WiFi or timed out when trying to connect to server.

after removing this part the result still the same , if internet connection is lost and back again , streaming is stopped and the error is " not connected "
is it a bug ?

from firebase-esp8266.

mobizt avatar mobizt commented on May 24, 2024

My mistake, the above comment about WiFi AP_STA mode is not neccessary, you can start the device as server under the local network which I still not understand what you're trying to do with server.

The use as WiFi server and client together is not recommend.

You need to debug the WiFi is only way to investigate the problem. The library report the status of WiFi client directly but need to debug for the reason.

from firebase-esp8266.

DavidSAlexander avatar DavidSAlexander commented on May 24, 2024

My mistake, the above comment about WiFi AP_STA mode is not neccessary, you can start the device as server under the local network which I still not understand what you're trying to do with server.

The use as WiFi server and client together is not recommend.

You need to debug the WiFi is only way to investigate the problem. The library report the status of WiFi client directly but need to debug for the reason.

i already did that , here's what i got from the debug :

Can't read stream data
REASON: not connected
Stream timeout, resume streaming...

Note that this result is the same as the internet alive and streaming is connected !
what i did for debugging and testing :
connect the device to the wifi
wait the firebase streaming to successfully connect
read a change successfully
unplug the telephone cable from my router ( no internet )
check the serial monitor still the same as above
plug the cable again ( internet is back )
still the same result and no response
what i did is to simulate what happening if i have a bad internet connection or connection interrupt , and what i need to do is a self reconnect to the internet if internet is back .
note that if restart my router , the device is automatically reconnect and streaming is successfully resumed again .
thanks for your time .

from firebase-esp8266.

mobizt avatar mobizt commented on May 24, 2024

I mean WiFi debug in Arduino IDE, from Tools > Debug Level.
You still not tell me why you start the sever with server.begin();.

I saw you use by include WiFiManager, DNSServer, ESP8266WebServer, Is it your code or you copy from internet?.

You may have many idea how to build your system but the real implementation, you need to test everything separately that it works and add that to your code step by step, test it with your existing system that it works properly under the system.

You need to always debug the heap and stack memory which are consumed by every library you used and your own code because low memory lead to unexpected fault.

No matter what you're trying, ESP8266 itself trying to reconnect WiFi when it lost.

The library try it best to recover the internet connection as I post this #29 (comment).

You need to investigate and debug yourself. Try to connect WiFi with normal and clean method without any library except for Firebase and ESP8266WiFi.

from firebase-esp8266.

DavidSAlexander avatar DavidSAlexander commented on May 24, 2024

here's the wifi debug after connecting the wifi and unplug then plug the telephone cable :
debug

server.begin(); is used for local server
WiFiManager, DNSServer, ESP8266WebServer
are libraries to manage wifi settings so that i don't need to reconfigure wifi if wifi network name changed, and all i need is to create an access point and connect to , then open a specific local web page and reconfigue the wifi settings.

You need to investigate and debug yourself. Try to connect WiFi with normal and clean method without any library except for Firebase and ESP8266WiFi.

actually i did that and result is the same !
streaming lost and never back again if internet interrupted !
streaming back again if i resetart my router ( not my NodeMCU ) so that it;s NOT a heap or memory problem .

from firebase-esp8266.

mobizt avatar mobizt commented on May 24, 2024

Try the following.

  • Connect to another WiFi hotspot.
  • Connect to soft AP created with your computer.
  • Connect to your mobile phone WiFi hotspot.
  • Try the following post

from firebase-esp8266.

mobizt avatar mobizt commented on May 24, 2024

I understand about WiFiManager, know it and ever use it. Lets try my above solution.
The problem may be the WiFi core lib or router which you need to try yourself.

Sorry I will close the issue because it's not relate to library anymore.

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.