WebServerST Crashes (Apparently with Apple Device Connection)

Well, I’m using the WebServerST from SurferTim with some modifications. (Attached)

But sometimes, with or without connections, the arduino crashes and no longer responds. Unless I restart it.
The last log transmitted:

Client request #36:GET /IO.XML? HTTP/1.1
file= /IO.XML
file type= XML
method= GET
params=
protocol= HTTP/1.1
XML request
Sending XML reponse…Sent.Disconnected.

Sometimes, it receives a request to Apple Device Icon and also crashes.

Client request #5:GET /apple-touch-icon.png HTTP/1.1
file= /APPLE-TOUCH-ICON.PNG
file type= PNG
method= GET
params=
protocol= HTTP/1.1
SD file
Filename format OK.
File not found!
Disconnected.

PS: When it crashes, the output pins (6,7,8,9) became in logical HIGH level.

Some help to avoid this request or find something else that may be crashing it?

Another thing, I search before starting this topic, and the only thing I got was stop receiving requests for favicon.ico with this code in the HTML page:

<link rel="icon"href="data:;base64,iVBORw0KGgo=">

WebServerST.zip (5.09 KB)

Are you using a Mega2560? If you are trying that with an Uno, you may be running out of SRAM.

I'm using Arduino UNO. And how to avoid the Apple Device Icon request?

Like I said, you may be running out of SRAM. If you left the freeRam function in the script, you can call it to see how much SRAM you have remaining. If you run out, it doesn't show zero. It will report a negative or unrealistic high value.

If you run out of SRAM, your script will become erratic and unreliable. The SRAM loops back onto itself, causing crashes and runtime errors.

edit: The apple icon request should not crash the server. It will return an error 404 (file not found) or error 400 (bad request), then go about its normal business.

I did a test of the request for the apple icon, and mine returned FILE NOT FOUND. It did not crash.

In my test, I get 380 bytes free from SRAM.

Client request #3:GET /apple-touch-icon-120x120.png HTTP/1.1 file= /APPLE-TOUCH-ICON-120X120.PNG file type= PNG method= GET params= protocol= HTTP/1.1 SD file Filename format OK. File not found! Disconnected. SRAM =380

After this log (Where has a return function :293), my Arduino froze. I guess, the SRAM isn't the problem. But I don't know what's wrong.

This is a wrong guess? :slightly_frowning_face:

Are you calling freeRam in the loop or in checkServer? If you are calling it in loop, it will not take into account all the SRAM required by checkServer, and that is considerable.

Is the SRAM available the same every call? It should be. If it is not, you may have an array overflow.

SurferTim:
Are you calling freeRam in the loop or in checkServer? If you are calling it in loop, it will not take into account all the SRAM required by checkServer, and that is considerable.

Is the SRAM available the same every call? It should be. If it is not, you may have an array overflow.

I called freeRam in sendBadRequest and sendFileNotFound function (Lines 359 and 370), and get this log.

The last log, occurred a strange thing. See the attachment log.txt

WebServerST.ino (12.7 KB)

log.txt (14.7 KB)

You have apparently overflowed something. I can't test it from here because I have a Mega2560. It has a bunch more SRAM than the Uno.

SurferTim: You have apparently overflowed something. I can't test it from here because I have a Mega2560. It has a bunch more SRAM than the Uno.

Apparently I solved the problem. When I called the sendBadRequest and sendFileNotFound functions, the variable tBuf is declared again. I just send the tBuf variable as a parameter to save memory.

I'll continue testing...

Nice catch. I didn't notice that. I may change tBuf to a global variable and remove the declarations locally in the playground code.

The arduino doesn't crash more. But, when I try to request a PNG file, the arduino can't find them...

Client request #1: GET /apple-touch-icon.png HTTP/1.1 file = /APPLE-TOUCH-ICON.PNG file type = PNG method = GET params = protocol = HTTP/1.1 SD file filename format ok File not found disconnected

Do you have any idea what's going on?

Tim Sir,

I want tell my hearty thanks to you, because you have replied and solved so many problems of many people for the last few years.

Here I want to as One question to you. I am using following things for my task.

Board : Mega 2560.
Ethernet shield : Wizne W5100 + 8 GB SD card.
configured IPs are:
IPAddress ip( 192,168,1,75 ); // Ethernet shield IP
IPAddress gateway( 192,168,1,1 ); //IPAddress gateway
IPAddress subnet( 255,255,255,0 ); //subnet mask

PICs : see attachments.

I have done task like ICMP-PING,send data to Remote Clinte IP. Now I need to load a webserver with SD card…like you example code WebServerSTCode and followed each and every steps as mention at that page.Okey. I create a index.htm(see attachment of html code) file on the SD card with help of SD_card reader.

If I open a page as

http://192.168.1.75/MYTEST.PHP

and its working and happy.

Now my trouble starts that if open pate at crome as

http://192.168.1.75/index.htm

and browser shows as

FILE NOT FOUND

and I attached Serial_output.

My goal is taking input strings from the page and store into my code. like example of

/MYTEST.PHP

and do more …

Sorry for bad English and thanking you in advance.
----- Manjunath

Serial_Ouput.txt (234 Bytes)

index.txt (241 Bytes)

Thanking you Authors: SurferTim,Peter_n, Zoomkat and W.A. Smith, http://startingelectronics.org

Great day for me. After struggling for 2 months My expecting result, out-put has come.

Its already done projects for few years back and just I modified code according to my requirements.

I have to do more with this…like interfacing Simcom modem,I2c based RTC and memory…

I want to share my code, for who struggling with interfacing Ethernet+SD Card with Mega2560.

I have connected my Ethernet shield to router and my PC connected to router through LAN cable.

I copied inded.htm file into SD card with SD_card reader. you can see pics.

Thanking you all and pardon me for my bad English…

Manjunath

WebserverSdIndex_Success.ino (4.8 KB)

index.txt (241 Bytes)