Any way to make this non-blocking ?

At the end of an HTTP client connection if I call client.close too quickly browsers don't get the whole page; the footer and maybe some trailing HTML cuts off. So I call delay(250) and it works, trouble is I'm wasting time in that delay stall.

Any way to make that non-blocking like we do in LED activity?

  client = server.available();
  if (client) {  
   ...
    if url==foo { this/that type stuff...
    }
   ...

  delay(250);
  client.stop();
  }

Finite state machine.

call client.flush() right before client end. That still blocks but only long enough for the outgoing transmission to end.

Delta_G: call client.flush() right before client end. That still blocks but only long enough for the outgoing transmission to end.

In lieu of client.stop? Or are call .stop after .flush?

EDIT: If I don't call client.stop the browser spins away terminally. So I put .flush above .stop and removed the delay but the pages still don't reliably complete. Could it have to do with footer includes that pull in from public servers? I'm going to try serve them locally to speed things up. Might be on the wrong path though.

If you are using Connection: close, perhaps waiting for client.connected() to return false will do the job. Which HTTP library are you using? Where is the documentation for it? That's the first place to look, you know.

Can you use the Blink Without Delay technique to use millis() for non-blocking timing. See also Several Things at a Time

...R

PaulMurrayCbr: If you are using Connection: close, perhaps waiting for client.connected() to return false will do the job. Which HTTP library are you using? Where is the documentation for it? That's the first place to look, you know.

So instead of calling Connection: close in each if/else, you're suggesting removal and placing just one after I close out client.connected() ?

Here's a snip of what's occurring ~35 times

else if (req.indexOf("/pool/water/temp") != -1) {
            client.println(F("Content-Type: text/plain"));
            client.println(F("Connection: close"));
            client.println();
            client.print(F("[{\"waterTemp\":\""));
            client.print(poolTemp);
            client.print(F("\"}]"));
          }
          else if (req.indexOf("/pool/pump/rpm") != -1) {
            client.println(F("Content-Type: text/plain"));
            client.println(F("Connection: close"));
            client.println();
            client.print(F("[{\"pumpRPM\":\""));
            client.print(pumpRPM);
            client.print(F("\"}]"));
          }
          else if (req.indexOf("/pool/pump/watts") != -1) {
            client.println(F("Content-Type: text/plain"));
            client.println(F("Connection: close"));
            client.println();
            client.print(F("[{\"pumpWatts\":\""));
            client.print(pumpWatts);
            client.print(F("\"}]"));
          }

Maybe your web page content isn't complete...? The browser will usually close the session once the appropriate HTML tags have been balanced.

Innocent omissions cause all sorts of issues - i've done it a few times

lastchancename:
Maybe your web page content isn’t complete…?
The browser will usually close the session once the appropriate HTML tags have been balanced.

Innocent omissions cause all sorts of issues - i’ve done it a few times

It is complete, because pressing F5 once or twice will yield a full load (and not CTL-F5, but that works, too). Seems like a timing issue in the code. I didn’t intend for this to veer into HTML structure but thought since you questioned it I’d post the page source for a good and failed page load. The whole page is too large to post here.

Good load: http://pastebin.com/1Hs7G1sj

Failed load: http://pastebin.com/hT3b575d

It’s as if the page just ceases to load and moved on before completing.