-->
Page 1 of 2

ESP8266 Web Server --some browser requests are timing out

PostPosted: Sun Jul 08, 2018 11:59 am
by Sirquil
Some browser HTTP Requests to ESP8266 Web Server are timing out; is there a way to correct? There are no sleep commands in"NTP_Time-Synced_Web_Interface."

Have Googled sleep commands. Confused on how to apply; what would be used in the case of a web server to trigger a GPIO pin?

Website having some requests needing reloading: https://tinyurl.com/Treyburn-weather

William

Re: ESP8266 Web Server --some browser requests are timing ou

PostPosted: Sun Jul 08, 2018 4:15 pm
by btidey
I think it will help if you can say a bit more about what server requests are being done.

I can't find any server.on set ups which would normally be used to configure the requests the server will respond to. Likewise I can't see any server.handleClient calls which gives the server the opportunity to respond to requests.

It looks like the server is just supporting readFile in a polled fashion. Is that right? One then needs to know how often the readFile is being called.

It might be worth considering using the FSBrowser method for supporting reading Files on the server.

Personally I don't like the strategy of splitting a giant ino across lots of ino files. Although this may seem to be a modular approach, in reality it is still a giant ino file but with the disadvantage that it is trickier to search for stuff. I think it is easier to understand if the code is modularised in the form of libraries or classes.

Re: ESP8266 Web Server --some browser requests are timing ou

PostPosted: Sun Jul 08, 2018 5:29 pm
by Sirquil
Brower requests are handled by listen function. All of the tabs to the right of "NTP_Time-Synced_Web_Interace.ino" are functions. Once the server has a GET request it is evaluated according if conditionals. Server requests for Weather, SdBrowse, and Graphs all occasionally take longer and timeout -- on the 1st request of a browser session; however, request can be reloaded okay. After the first request pages load quickly.

Weather page is created dynamically and produced after reading BME280 sensor.

I am a hobbyist/programmer, self taught and only recently learned of the ESP8266 Web servers.

Response time from server is 1 to 2 seconds; file downloads are very fast using readFile function.

I just started using tabbed compiling; I do see your point regarding searching for something.

William

Re: ESP8266 Web Server --some browser requests are timing ou

PostPosted: Mon Jul 09, 2018 2:36 am
by btidey
OK. I can see you are doing your own server parsing in listen. Lack of response is going to be either a problem in listen itself or that listen is not called often enough.

I am not sure why you have chosen this route to the server side handling. It seems a bit complex and complexity leads to behaviour more difficult to understand.

The method used in many cases for server side handling is to define server.on handlers in setup and then just call server.handleClient regularly within the loop. This will automatically call the requisite handlers when GET or POST requests are received. One can also have a catch all server.onNotFound to handle requests not catered for in other server.on

For example

server.on(("/Weather", handleWeatherData); in setup
and
server.handleClient(); in loop

will call the void handleWeatherData function when a request to /Weather is made. This function can end up just doing a
server.send(200, "text/html", response);

Any number of server.on can be put into setup which then modularises the code quite effectively.