Comments (8)
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.
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.
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.
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.
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.
here's the wifi debug after connecting the wifi and unplug then plug the telephone cable :
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.
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.
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)
- ESP8266 is crashing while writing to firebase realtime database HOT 5
- soft wdt reset issue in esp8266 HOT 1
- I'm trying to read this data HOT 2
- WiFiClientSecure issue HOT 6
- Get Token status HOT 1
- issuse HOT 14
- BUG Token info: type = id token (GITKit token), status = on request HOT 1
- PLEASE HELP HOT 3
- [HELP] Cannot connect esp8266 and firebase. Compilation error: invalid conversion from 'int' to 'FirebaseConfig*' {aka 'firebase_cfg_t*'} [-fpermissive] HOT 1
- I've been getting a connection refused after a few seconds
- I've been getting a connection refused after a few seconds after connection to firebase HOT 1
- HELP : Executed HTTPS and connection Firebase HOT 2
- HELP :: captivePortal and firebase connection HOT 4
- BUG FirebaseESP8266.h with version @^4.4.12 of Library HOT 4
- FirebaseJson is confilcted with json inside ESP8266WebServer library HOT 6
- HELP
- Content Available for FCM_HTTPv1_JSON_Message HOT 1
- Unable to Fetch Data from Firebase
- Wi-Fi Reset Doesn't Initialize Firebase Variables and LED Status Doesn't Update Post-Reconnection HOT 6
- ERROR CODE: -3, REASON: NOT CONNECTED STREAM TIMED OUT, RESUMING... HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebase-esp8266.