Code Monkey home page Code Monkey logo

Comments (11)

sandeepmistry avatar sandeepmistry commented on July 19, 2024

Hi @mamama1,

I've been able to reproduce the issue with WiFi101 v0.10.0 + WiFiWebServer example + Chrome on OS X and pounding CMD-R to refresh the browser.

I tried with the changes in #77 and could not reproduce. In any case, I've pushed some new changes to my socket-buffer branch. Could you please download the latest and try again?

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

@mamama1 could you also provide more details on what hardware you are using (MKR1000, WiFi101 shield + Uno, etc).

The testing I mentioned above was done on a MKR1000 board.

from wifi101.

mamama1 avatar mamama1 commented on July 19, 2024

Hi @sandeepmistry

Thanks for investigating!
As commented in your #77, I did try this with your socket rework initially (unsuccessfully).
However, I'll try again with the most recent version and report back as soon as I find some time.

I'm using the Adafruit WINC1500 Breakout Board + Atmega2560 (Arduino Mega). I also tried with the Uno, same results.

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

Hi @mamama1,

The latest version of #77 seems ok with my WiFi101 Shield + Uno. Looking forward to hearing about your test results.

I will see if there's a smaller fix we can do in the mean time.

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

A quick update, I've pushed another change to #77. Things seem better when I hold CMD-R for ~30s on OS X + Chrome.

It doesn't look we can do a smaller fix to resolve it.

from wifi101.

mamama1 avatar mamama1 commented on July 19, 2024

Hi @sandeepmistry,

I've tried https://github.com/sandeepmistry/WiFi101/archive/socket-buffer.zip and I've tried https://github.com/sandeepmistry/WiFi101/archive/master.zip

Both with no luck, unfortunately. Basically the same behaviour.

This is the serial monitor output of the last two requests, before the code hangs:

client disonnected
new client
GET / HTTP/1.1
Host: 192.168.25.161
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4

client disonnected
new client
GET / HTTP/1.1
Host: 192.168.25.161
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: client disonnected

from wifi101.

mamama1 avatar mamama1 commented on July 19, 2024

i did this (Serial.println("a"); and Serial.println("c");) to know the status when it hangs, and again the serial monitor is spammed with c characters so I guess "client" is still/again connected but not "available".

while (client.connected()) {
Serial.println("c");
if (client.available()) {
Serial.println("a");
char c = client.read();
Serial.write(c);
....

from wifi101.

mamama1 avatar mamama1 commented on July 19, 2024

Hi @sandeepmistry,

i was wondering if this will ever get resolved. is it related to the atmel firmware?

thanks

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

@mamama1 if you are still interested in this, could you please try the changes in PR #204. Thanks.

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

I'm closing this for now due to lack of feedback, please re-open if you are still interested and have tried the changes for PR #204 which have been merged.

from wifi101.

i486you avatar i486you commented on July 19, 2024

The problem is that some web browsers request for favicon.ico. Chrome requests it every reload but Firefox, Safari and IE don't.

And the sample code does not check the second request for favicon.ico. So I edited some of them.

This question is posted in 2016. However, the sample code and the library ESP8266Wifi have not fixed. So I hope this code helps someone.

void WaitWebClient()
{  
     WiFiClient client = server.available();

     // wait for a client (web browser) to connect
     if (client)
     {
          Serial.println("\n[Client connected]");

          // <<<<<<<<< Added
          // In chrome browser, if you close the tab or window opened during a request
          // client.connected() will be true and client.available() will be zero.
          int cntToBreak = 0;

          while (client.connected())
          {
               // available() returns the size of message.
               if(client.available())
               {
                    String line = client.readStringUntil('\r');
                    client.readStringUntil('\n');        // <<<<< Added
                    Serial.print(line);
        
                    // wait for end of client's request, that is marked with an empty line
                    // <<<<<<<<<<< Modified
                    if(line.length() == 0)
                    {
                         client.println(prepareHtmlPage());
                         break;
                    }

                    Serial.println();
                    Serial.println(line.length());
               }

               // <<<<<<<<<<<<< Added
               // Client is connected but no message.
               // then count the times of this loop.
               else
               {
                    if(cntToBreak++ > 20)
                    {
                         cntToBreak = 0;
                         break;
                    }
               }
          }
         delay(1); // give the web browser time to receive the data

          // close the connection:
          if(client.stop())
          {
               Serial.println("[Client disonnected]");
          }
     }
}

from wifi101.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.