espressif / arduino-esp32

Arduino core for the ESP32

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"HTTPClient::end(void)" runs are too long

xiruilin opened this issue · comments

In /libraries/HTTPClient/src/HTTPClient.cpp, function "void HTTPClient::end(void)", line 231:

    if(_tcp->available() > 0) {
        log_d("still data in buffer (%d), clean up.", _tcp->available());
        while(_tcp->available() > 0) {
            _tcp->read();
        }
    }

If the unread data is very large, it will take a long time. If changed to:

    if(_tcp->available() > 0) {
        log_d("still data in buffer (%d), clean up.", _tcp->available());
        _tcp->flush();
    }

You can achieve what you want.

Hi,
I can confirm that I have this issue also, takes around 60 seconds to close the http connection when trying to close a streaming radio station, like http://streaming.shoutcast.com/80sPlanet?lang=en-US
There was no issue with the original code when using an ESP8266, so not sure what has changed.

xiruilin's above change to library does resolve the issue for me.

can we make a pull request for this?

edit: created a request. i also had difficulties with the radio stream taking easily more than the 60 seconds(!) to return from http.end()