Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xiruilin opened this issue Nov 11, 2017 · 2 comments
Closed

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

xiruilin opened this issue Nov 11, 2017 · 2 comments

Comments

@xiruilin
Copy link

xiruilin commented Nov 11, 2017

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.

@Uksa007
Copy link

Uksa007 commented Feb 6, 2018

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.

@h3ndrik
Copy link
Contributor

h3ndrik commented Feb 6, 2018

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()

h3ndrik added a commit to h3ndrik/ESP8266Audio that referenced this issue Feb 6, 2018
h3ndrik added a commit to h3ndrik/arduino-esp32 that referenced this issue Feb 6, 2018
flush tcp buffer instead of reading it byte by byte.
Curclamas pushed a commit to Curclamas/arduino-esp32 that referenced this issue Aug 21, 2018
flush tcp buffer instead of reading it byte by byte.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants