khoih-prog / EthernetWebServer

This is simple yet complete WebServer library for AVR, AVR Dx, Portenta_H7, Teensy, SAM DUE, SAMD21/SAMD51, nRF52, STM32, RP2040-based, etc. boards running Ethernet shields. The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32. Coexisting now with `ESP32 WebServer` and `ESP8266 ESP8266WebServer` libraries. Ethernet_Generic library is used as default for W5x00 with custom SPI
MIT License
178 stars 49 forks source link

Ethernet_Large + Lib Patches give always IP:255.255.255.255 || can not server.streamFile () from SPIFFS #19

Closed ArminPP closed 3 years ago

ArminPP commented 3 years ago

Hello, I'm trying to set up a web server with a W5500 Shield (and a m5Stack). Since I use Bootstrap and the files are> 40 kB (up to 200 kB) I used the Ethernet_Large Library. Without your lib patches, the html part loads, but the ESP crashes with the large css + js files. When I import your lib patches, I only get IP: 255.255.255.255 addresses, regardless of whether I choose static or dynamic. (If I use the original Ethernet_large sources again, I get the correct IP address)

Unfortunately loading SPIFFS doesn't work with your library:

  File file = SPIFFS.open ("/bootstrap.min.css.gz", "r");
  size_t sent = server.streamFile (file, "text/css");

so I added another library: Effortless_SPIFFS.h https://github.com/thebigpotatoe/Effortless-SPIFFS This loads the files stored in SPIFFS into a string at lightning speed, which I then transfer to your lib: Unfortunately the Effortless_SPIFFS doesn't load and extract .gz files (which will server.streamFile() do and server.send() not, I presume ), so I have to use the uncompressed ones ...

bool handleFileRead (String path) {
  String sHTML;
  char cPath [20];
  if (path.endsWith ("/")) path + = "index.html";
  if (SPIFFS.exists (path)) {
    path.toCharArray (cPath, 20);
    String contentType = getContentType (path);
    fileSystem.openFromFile (cPath, sHTML); // <- Effortless_SPIFFS.h
    server.send(200, contentType, sHTML);
    return true;
  }
  return false;
}

Is it possible, to load Files large than >40 kb from SPIFFS and send it to server() - directly with Ethernet_Large, and server.streamFile() or with server.send() ?

Thank you verry much,, Armin

khoih-prog commented 3 years ago

Congrats on your project's quick advancement.

There are many known issues with ESP32 and W5x00 libraries, relating to SPIFFS as you can see in Spiffs not work.

There is also the possible problems caused by the Ethernetx libraries on which this EthernetWebServer library is relying. Also keep in mind that these libraries and MCUs, even ESP32, have limited capability and can't be expected to work as fast and good as the PCs.

I'm sure that the patched EthernetLarge library is working OK. The IP: 255.255.255.255 issue is caused by something in your code. Test using one of the examples to know for sure and compare. If you can provide some code the duplicate this IP issue, I can help you there.

I just can suggest you test step-by-step

  1. Change the Ethernet library to Ethernet2, Ethernet3
  2. Use the Ethernetx libraries directly to isolate where the problem is.
  3. Using native ESP32 WiFi for your application
  4. Try new ESP32 LittleFS instead of slower and to-be-deprecated SPIFFS
  5. Using SD card instead of SPIFFS/LittleFS
  6. Conflict on SPI bus

image

There is no way I can help you solve this problem without much info or code to duplicate the issue.

I'll close the issue now as it seems to me that the problem is caused be other libraries / configuration / core.

Good Luck,