I'll just start with the short version ..... giving you more info after that
-
I have in my Arduino 2560 baically the Example Webserver (added one input box to send commands back to webserver and added my own text data sent to client ).
-
I contact my Webserver over local LAN from my PC with Firefox.
-
The setup is to send commands to Webserver and get back info from sensors on the 2560. All that via my Firefox browser in PC.
The problem I have is that my PC (well basically Firefox) send GET requests to my Arduino when I am NOT actually submitting from my browser input box. Apart from that everything is working good. I can send requests and get proper information back in my browser window.
A typical problem would be.
- I send some commands and get proper answers back
- I leave the browser window open, not using, for like 4 minutes
- I click a + tab in browser and open new tab
This trigger a GET request sent from my PC to Arduino
Typically e.g.
http://192.168.1.177/?LED=z10+33&submit=Byt
Byt is my label for input box send knob
z10 33 is my command box text
If I try open new tab before 4 min wait I don't see the problem
Why is browser sending these requests when I'm not active on the input box ?
More details if you did not stop before this ![]()
Trying to google like "GET resend open tab firefox" or variants just gave much hits not related.
So I've spent a lot of time trouble shooting using Wireshark on my PC.
For a while I thought I had a solution by commenting out a keep-alive parameter sent from my Webserver (see code)
But problem still exist, just maybe not seen at every attempt to provoke problem
I verified on PC all old ports was properly closed (except the open one to port for my last command from input box) Before I provoke error by open new tab.
It might look like a pure browser/Firefox problem. I'm just not educated enough to be sure if it might be related to my Webserver code.
Frustrated now from not understanding this weird problem. My webserver get resent my old commands. This at risk of starting not wanted actions on Arduino. Like activating some relay etc.
It's always the exakt same GET request being sent as long as my browser session is not restarted. After restart it might be another GET request. Some of them I sent in the new session. Didn't find any logic in what request get "choosen". It's not the last true command I sent. It's not the first command sent in session.
Webserver code in attached file.
Here's the client.println bits of code:
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank ) {
// send a standard http response header
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: text/html"));
/*client.println(F("Connection: close")); // the connection will be closed after completion of the response
client.println(F("Refresh: 5")); // refresh the page automatically every 5 sec*/
client.println();
client.println(F("<!DOCTYPE HTML>"));
delay(1000);
..........
/////////////////////// Web output ////////////////////////////////
// output the value temp and humidity
client.println(F("Humidity:     "));
client.println(h);
client.println(" %\t");
client.println(F("
"));
client.println(F("Temperature: "));
client.println(t);
client.println(F(" *C "));
client.println(F("
"));
client.println(F("Temp satt:     "));
client.println(targettemp);
client.println(F(" *C "));
client.println(F("
"));
if (pstat == 1) {
client.println(F("Temp is on"));
}
...................................
client.println(F("<FORM ACTION=\"http://192.168.1.177\" method=get >"));
client.println(F("Kommando <INPUT TYPE=TEXT NAME=\"LED\" VALUE=\"\" SIZE=\"25\" MAXLENGTH=\"50\">
"));
client.println(F("<INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\"Byt\">"));
client.println(F("</FORM>"));
client.println(F("
"));
client.println(F("</html>"));
.............................
WebServerSD2560.ino (18.1 KB)