From 5c24375b8af10add2326da25818636ad1d1525f9 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 28 Dec 2017 08:01:02 +0800 Subject: [PATCH] ESP8266HTTPClient: allow changing connection timeout using setTimeout Call Client::setTimeout before connection to influence connection timeout. Closes https://github.com/esp8266/Arduino/issues/3451. --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index 0abc66fa4e..ad8b14892d 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -840,6 +840,7 @@ bool HTTPClient::connect(void) } _tcp = _transportTraits->create(); + _tcp->setTimeout(_tcpTimeout); if(!_tcp->connect(_host.c_str(), _port)) { DEBUG_HTTPCLIENT("[HTTP-Client] failed connect to %s:%u\n", _host.c_str(), _port); @@ -854,8 +855,6 @@ bool HTTPClient::connect(void) return false; } - // set Timeout for readBytesUntil and readStringUntil - _tcp->setTimeout(_tcpTimeout); #ifdef ESP8266 _tcp->setNoDelay(true);