lasselukkari / aWOT

Arduino web server library.
MIT License
283 stars 41 forks source link

Curl hangs up when retrieving JSON on version 3 #90

Closed Jauwaad closed 3 years ago

Jauwaad commented 3 years ago

Not sure this is because of HTTP 1.1. But the data is retrieved after the curl call times out.

lasselukkari commented 3 years ago

There a are differences in wifi/ethernet libraries on do they close the socket in the class destructor or not. Sounds like yours does not. By default the server expects the connection to be closed after every request and because of this the connection: close header is used. The curl is most likely just waiting for the connection to be terminated by the server.

Try changing your loop to something like this:

void loop(){
  EthernetClient client = server.available();
  if (client.connected()) {
    app.process(&client);
    client.stop(); // add the client stop here
  }
}
lasselukkari commented 3 years ago

As expected the library does not close the socket automatically. It does not have destructor specified at all. https://github.com/arduino-libraries/WiFiNINA/blob/master/src/WiFiClient.h. Manually closing the client after processing should do the trick. This is the fist wifi library that I see working this way around. I will update the readme to contain a compatibility section.

Jauwaad commented 3 years ago

Calling client.stop() resolved this issue. Thanks for the help. Great library.