Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By weekendguy
#70246 I'll admit this is weird, and I have been chasing it off and on for a few months. Basically, I built an ESP-based heating system control that provides a web interface. I have this port forwarded so I can get to it from outside my firewall using a specific port. It works from everywhere - has no problems EXCEPT when I try to use it from my Verizon Wireless phone. The page just hangs. So I connected my development laptop to the mobile hotspot on the phone and tried it. Same problem - no joy. When I packet capture, I see that in a working case the server provides this:

HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 2201
Connection: close

<!DOCTYPE html><html><head><meta http-equiv="Cache-control" content="no-transform">...
...followed by the rest of the page.

In the failure mode, I get this only:

HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 2201
Connection: close

In both cases, the header info above is in the first TCP packet. When it's working the remainder of the page is broken up over 2 more packets. In the failure mode, data ends after the header packet. If I am reading the wireshark data correctly it seems like multiple packets are expected but no more are sent.

I should note that I have captured packets from behind the firewall and I am watching all data coming to/from the ESPWebserver. So why would it stop sending? Is it missing an ACK? Or is this related to MTU size and packet fragmentation? I feel like it's in the networking layers. All my devices are set to MTU=1500.

I know this sounds improbable but I sat down 4 times to solve it and still can't come up with a solution. I just moved my home Internet from Comcast to FIOS so I was waiting until that change was complete in case there was any effect. Still have the same problem. This is the layout:

ESP<---->unifi WAP<------>wired to sonicwall<----------->FIOS

I have some packet traces in .pcap form. Anything I am missing?
User avatar
By tele_player
#70300 I just tried something similar. I used the AdvancedWebServer example, set to port 8080, modified to send about 2100 bytes of text, using /inline handler. Set up port forwarding on my Asus WiFi AP, connected from my Android phone on AT&T.

It worked perfectly.

There are many differences between my setup and yours. I'd try using the AdvancedWebServer example, see if that behaves differently.
User avatar
By weekendguy
#70364 Thank you for the comment. I'm glad to know it works for you. I'll try to use a small case like the example you mentioned and build up from there. I am also using WebUpdateServer in the same code - which works fine, but I'm now wondering if there are any conflicts.
User avatar
By weekendguy
#70374 @tele_player: Thank you for your suggestion. I used the AdvancedWebServer and it failed exactly as before. To test, I dropped about 1600 characters of my html into the "temp" variable and accessed it via "handleroot". In each test (wifi and mobile), I first used /inline to be sure I had a simple connection, then "/" to execute the root handler. Wifi works, mobile fails in the same manner (I have packet traces). Would you please try this code in your environment to see if somehow Verizon wireless is the culprit? I'm reluctant to call "bug" until I'm really sure I'm not causing it. Code below. Many thanks.

Code: Select all/*
 * Copyright (c) 2015, Majenko Technologies
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright notice, this
 *   list of conditions and the following disclaimer in the documentation and/or
 *   other materials provided with the distribution.
 *
 * * Neither the name of Majenko Technologies nor the names of its
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char *ssid = "ssid";
const char *password = "password";

char temp[2100];

ESP8266WebServer server ( 80 );

const int led = 13;

void handleRoot() {
   digitalWrite ( led, 1 );
 
   sprintf ( temp,
"<!DOCTYPE html> \
<html> \
    <meta http-equiv=\"refresh\" content=\"10\"> \
    <font size=\"5\" color=\"white\"> \
        <p style=\"text-align:left;font-size:30px\"> \
            <body bgcolor=blue> \
                &nbsp;&nbspBoiler Control<span style=\"float:right;\">2:05:28 pm &nbsp;&nbsp;&nbsp;&nbsp \
        </p><style> \
            table, th, td { \
                border: 2px solid black; \
                border-collapse: collapse; \
            } \
            th, td { \
                padding: 5px; \
                text-align: left; \
            } \
        </style> \
        <table style=\"width:100%\">\
            <tr>\
                <th width=\"25%\">Sensor</th>\
                <th width=\"25%\">Temp</th>\
                <th width=\"25%\">Sensor</th>\
                <th width=\"25%\">Temp</th>\
            </tr>\
            <tr>\
                <td>TNK</td>\
                <td style=\"color:white\">124 &deg;F</td>\
                <td>HOT</td>\
                <td style=\"color:white\">95 &deg;F</td>\
            </tr>\
            <tr>\
                <td>MIX</td>\
                <td style=\"color:white\">113 &deg;F</td>\
                <td>WRT</td>\
                <td style=\"color:white\">87 &deg;F</td>\
            </tr>\
            <tr>\
                <td>SUP</td>\
                <td style=\"color:white\">98 &deg;F</td>\
                <td>BRT</td>\
                <td style=\"color:white\">94 &deg;F</td>\
            </tr>\
            <tr>\
                <td>ZRT</td>\
                <td style=\"color:white\">86 &deg;F</td>\
                <td>D-T &nbsp;&nbsp (ZRT)</td>\
                <td style=\"color:white\">12 &deg;F</td>\
            </tr>\
        </table>\
        <p>\
        <p>\
        <br>\
        <br>&nbsp;&nbspVer.3.42\
</p></body>\
</html>");

   server.send ( 200, "text/html", temp );
   digitalWrite ( led, 0 );
}

void handleNotFound() {
   digitalWrite ( led, 1 );
   String message = "File Not Found\n\n";
   message += "URI: ";
   message += server.uri();
   message += "\nMethod: ";
   message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
   message += "\nArguments: ";
   message += server.args();
   message += "\n";

   for ( uint8_t i = 0; i < server.args(); i++ ) {
      message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
   }

   server.send ( 404, "text/plain", message );
   digitalWrite ( led, 0 );
}

void setup ( void ) {
   pinMode ( led, OUTPUT );
   digitalWrite ( led, 0 );
   Serial.begin ( 115200 );
   WiFi.begin ( ssid, password );
   Serial.println ( "" );

   // Wait for connection
   while ( WiFi.status() != WL_CONNECTED ) {
      delay ( 500 );
      Serial.print ( "." );
   }

   Serial.println ( "" );
   Serial.print ( "Connected to " );
   Serial.println ( ssid );
   Serial.print ( "IP address: " );
   Serial.println ( WiFi.localIP() );

   if ( MDNS.begin ( "esp8266" ) ) {
      Serial.println ( "MDNS responder started" );
   }

   server.on ( "/", handleRoot );
   server.on ( "/test.svg", drawGraph );
   server.on ( "/inline", []() {
      server.send ( 200, "text/plain", "this works as well" );
   } );
   server.onNotFound ( handleNotFound );
   server.begin();
   Serial.println ( "HTTP server started" );
}

void loop ( void ) {
   server.handleClient();
}

void drawGraph() {
   String out = "";
   char temp[100];
   out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"400\" height=\"150\">\n";
    out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
    out += "<g stroke=\"black\">\n";
    int y = rand() % 130;
    for (int x = 10; x < 390; x+= 10) {
       int y2 = rand() % 130;
       sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 140 - y, x + 10, 140 - y2);
       out += temp;
       y = y2;
    }
   out += "</g>\n</svg>\n";

   server.send ( 200, "image/svg+xml", out);
}