HttpClient library returning -1

Hi all!

I often get -1 as result of a simple http get.

After fiddling a bit I thought I had the necessity to change the timeout value in httpclient library or all my requests will return -1 (very long requests).

I have found this row in httpclient.ccp code that seems to be the key of my current issue:

static const uint16_t TIMEOUT = 5000; // Allow maximum 5s between data packets.

Is it possible to change this timeout value in ?

Thanks and happy hacking :smile:

That was an easy one, I excuse myself for such a silly question.

In case anybody else is struggling with the same issue it is sufficient to specify a different value of TIMEOUT before your setup()

static const uint16_t TIMEOUT = 15000; // Allow maximum 15s between data packets.

This way, even not changing the library the variable gets the correct value before starting the loop() section.

Sadly this was not enough to solve my issue :frowning:

I keep on getting -1 as result from HttpClient, even changing the timeout value.

Main thing is that this is not happening consistently…

As a workaround I am now handling cases when HttpClient’s result is -1 but that is, clearly, not fantastic.

Any suggestion / idea?

Hi @ltpitt,

Im having the same problem as yours. Did you find the solution?

Please see the other thread where I answered your question:

1 Like