wujiangang / ESP8266_IOT_PLATFORM

A demo that should be run with ESP8266 RTOS SDK
http://bbs.espressif.com
Other
239 stars 122 forks source link

Http server get stuck serving more than two files at the same time #6

Closed BLLuis closed 7 years ago

BLLuis commented 7 years ago

I'm starting using the platform with RTOS SDK v1.5 and I compile IOT platform demo, everything goes well except that some problems requesting files and the esp fs wasn't initialized, I made a modification to initialize and found another problem, the files where not aligned, so I made another modification as I found in the espressif forums and everthing started to run well except that the webserver get stuck when the browser request more than two files at the same time: index.html .js .png

The last one is never served, not even the request is logged from the device logs. If I request the files individually via telnet the files came fine but if the browser request the files via index.html so then request .js and .png the server get stuck. The module donesn't reset nor even hangs, just the sockets found no more request as far I can check looking at the sources. My level of knowledge about RTOS and sockets in this os is not enougth to check or know how to solve this problem. Maybe nobody has tested the example via html, because it works well via android app, but I want to make the server work properly. Looking at the repo of libesphttpd there are more newer files that the files in this repo, so, is very out of date and using an old version, again, my level is not enougth to change the code in such way yet.

Can you test this example with RTOS v1.5 and requesting files via http?

Today I put the content of .js .css inside the html so only two files are requested index.html and button.png and works well, this confirm my theory of stuck, also put the content of .js .css inside the wifi.tpl and works well. With this the requested files are two in the first step and only one in the wifi setup. But this is not a solution because if I want to add some more files and some of them are requested at the same time it will stuck again.

Below are some logs that the code send via serial port, there are modified by me and some other are added.

Another problem with the webserver is If I navigate from IE the only thing logged is W-index 1, sockfd 3, dummy?

In the logs I added I- W- E- for info, warning and error. and sometimes the name of the function. And in the file routines I changed the size of file and/or transfer from hex to decimal to make the data in log more uniform. Pointers are displayed in hex, just to know wich pointer is managed in the function.

I've posted the same question to bbs at espressif.com because I'm new with this platform and I don't know who follow wich form, the first question that somebody respond or if I got the solution I will update the post or close them to post the solution.

At the moment of logs, file compression was disabled to minimize the amount of logged data and to release module workload, but the problem is the same, with compression enabled or disabled.

Resuming:

I can get infinite number of times one or two files at the same time, via telnet or via Firefox, I made a batch that was running all night long and no errors serving files, but If I request three files like any browser should do because of index.html .js .css .png http get stuck. The module don't hangs nor reset, anything keep running well but the http server will serve no more files, not even only one, so the android app stop working.

I can't navigate using IE, no matter that this is an unused browser from the point of view of a developer, but there are a lot of people that only use IE.

Regards Luis

SDK version:1.5.0-dev(950076a),139 I-espFsInit test 0x3fff6070 mode : sta(5c:cf:7f:08:19:16) + softAP(5e:cf:7f:08:19:16) add if0 dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1) add if1 bcn 100 IOT VERSION:v1.0.5t23701(a) user_plug_init start! wifi_station_get_ap num 0 bcn 0 del if1 mode : sta(5c:cf:7f:08:19:16) .... ... ... I-httpserver_task started!!! smartconfig_task start .. ... captdns stack 18, heap 17272 ... ... I-httpserver acpt index:0 sockfd 3! I-Change of maxfdp 3 I-readable recv sockfd 3 len=322 I-xmitSendBuff about to send 113B on socket 3 I-xmitSendBuff write status 113 on socket 3 I-httpdProcessRequest cgi_done, marking socket for destruction 3 I-readable recv sockfd 3 ret=0, close I-closeAndFreeSocket 3 I-Change of maxfdp 0 I-httpserver acpt index:0 sockfd 3! I-Change of maxfdp 3 I-readable recv sockfd 3 len=332 I-espFsOpen file: index.html I- espFsOpen 0x3fff9990, p = 0x4022b76c I- Found file 'wifi/style.css'. Namelen=16 fileLenComp=386, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022b910 I- Found file 'wifi/140medley.min.js'. Namelen=24 fileLenComp=825, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022bc74 I- Found file 'wifi/icons.png'. Namelen=16 fileLenComp=914, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022c028 I- Found file 'wifi/connecting.html'. Namelen=24 fileLenComp=1255, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022c538 I- Found file 'wifi/wifi.tpl'. Namelen=16 fileLenComp=2503, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022cf20 I- Found file '140medley.min.js'. Namelen=20 fileLenComp=825, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022d280 I- Found file 'index.html'. Namelen=12 fileLenComp=1917, compr=0 flags=0 I-Found requested file I-File id: 3fff5aa8 (index.html) I-xmitSendBuff about to send 136B on socket 3 I-xmitSendBuff write status 136 on socket 3 I-Reading File id: 3fff5aa8 1024 bytes from 4022d29c I-cgiEspFsHook lwip_write status 1024 on socket 3 I-httpserver acpt index:1 sockfd 4! I-Change of maxfdp 4 I-readable recv sockfd 4 len=284 I-espFsOpen file: 140medley.min.js I- espFsOpen 0x3fff9990, p = 0x4022b76c I- Found file 'wifi/style.css'. Namelen=16 fileLenComp=386, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022b910 I- Found file 'wifi/140medley.min.js'. Namelen=24 fileLenComp=825, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022bc74 I- Found file 'wifi/icons.png'. Namelen=16 fileLenComp=914, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022c028 I- Found file 'wifi/connecting.html'. Namelen=24 fileLenComp=1255, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022c538 I- Found file 'wifi/wifi.tpl'. Namelen=16 fileLenComp=2503, compr=0 flags=0 I- espFsOpen 0x3fff9990, p = 0x4022cf20 I- Found file '140medley.min.js'. Namelen=20 fileLenComp=825, compr=0 flags=0 I-Found requested file I-File id: 3fff6090 (140medley.min.js) I-xmitSendBuff about to send 142B on socket 4 I-xmitSendBuff write status 142 on socket 4 I-Reading File id: 3fff5aa8 893 bytes from 4022d69c I-cgiEspFsHook lwip_write status 893 on socket 3 I-cgiEspFsHook finish sending file Id: 3fff5aa8 I-espFsClose 3fff5aa8 I- CGI done, mark for destruction 3 I-Reading File id: 3fff6090 825 bytes from 4022cf44 I-cgiEspFsHook lwip_write status 825 on socket 4 I-cgiEspFsHook finish sending file Id: 3fff6090 I-espFsClose 3fff6090 I- CGI done, mark for destruction 4 I-httpserver destruction close sockfd 3 I-closeAndFreeSocket 3 I-httpdserver sock_fd 4 timeout

BLLuis commented 7 years ago

Solved using another version of the same library https://github.com/Spritetm/libesphttpd