Skip to content

Core 3.1.1 - ESP8266HTTPClient.h getString() empty or truncated - read Timeout #8871

Open
@TobbeG

Description

@TobbeG

Basic Infos

  • [X ] This issue complies with the issue POLICY doc.
  • [ X] I have read the documentation at readthedocs and the issue is not addressed there.
  • [ X] I have tested that the issue is present in current master branch (aka latest git).
  • [X ] I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • [X ] I have filled out all fields below.

Platform

  • Hardware: [ESP01|
  • Core Version: [3.1.1]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Generic ESP8266 Module]
  • Flash Mode: [qio]
  • Flash Size: [1MB]
  • lwip Variant: [v2 Higher Bandwidth]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [160MHz]
  • Upload Using: [SERIAL]
  • Upload Speed: [460800] (serial upload only)

Problem Description

When I make https.GET not the all data received gets read into payload.

ESP8266Http library returms read Timeout

  • [HTTP-Client][returnError] error(-11): read Timeout

https.setTimeout(10000); does not help

Sending same query in web browser, reply is received within 2 seconds always.

Full XML response is around 3700 bytes, but only part of it is in payload (ie. some 1200 bytes but it varies from 0...3700)
despite that HTTP_CODE is 200 and [HTTP-Client] read chunk len is 3701

CODE:

    WiFiClientSecure *client = new WiFiClientSecure;
    int httpCode;
    if (client) {
      client->setInsecure();

          Serial.println(String(F("[ENTS]: Today url:")) + String(url));
          if (https.begin(*client, url)) {
            https.addHeader("Content-Type", "application/xml");
https.setTimeout(10000);
            httpCode = https.GET();
            Serial.println(String(F("[ENTS]: HTTP_CODE: ")) + String(httpCode));
            if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
              String payload = https.getString();
              Serial.println(String(F("[ENTS]: Length="))+String(payload.length()));
              Serial.println(payload);

### Debug printed with myown and HTTP_CLIENT DEBUG

[ENTS]: Today url:https://web-api.tp.entsoe.eu/api?securityToken=XXXXXXXXXXXXXX&documentType=A44&in_Domain=10Y1001A1001A46L&out_Domain=10Y1001A1001A46L&periodStart=202302262300&periodEnd=202302272300

[HTTP-Client][begin] url: https://web-api.tp.entsoe.eu/api?securityToken=XXXXXXXXXXXXXX&documentType=A44&in_Domain=10Y1001A1001A46L&out_Domain=10Y1001A1001A46L&periodStart=202302262300&periodEnd=202302272300

[HTTP-Client][begin] host: web-api.tp.entsoe.eu port: 443 url: /api?securityToken=XXXXXXXXXXXXXX&documentType=A44&in_Domain=10Y1001A1001A46L&out_Domain=10Y1001A1001A46L&periodStart=202302262300&periodEnd=202302272300

[HTTP-Client][sendRequest] type: 'GET' redirCount: 0
[HTTP-Client] connected to web-api.tp.entsoe.eu:443
[HTTP-Client] sending request header
-----
GET /api?securityToken=XXXXXXXXXXXXXX&documentType=A44&in_Domain=10Y1001A1001A46L&out_Domain=10Y1001A1001A46L&periodStart=202302262300&periodEnd=202302272300 HTTP/1.1
Host: web-api.tp.entsoe.eu
User-Agent: ESP8266HTTPClient
Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0
Connection: keep-alive
Content-Type: application/xml
Content-Length: 0

-----
[HTTP-Client][handleHeaderResponse] RX: 'HTTP/1.1 200 OK
'
[HTTP-Client][handleHeaderResponse] RX: 'Date: Mon, 27 Feb 2023 17:17:21 GMT
'
[HTTP-Client][handleHeaderResponse] RX: 'Server: Apache
'
[HTTP-Client][handleHeaderResponse] RX: 'Strict-Transport-Security: max-age=31536000 ; includeSubDomains
'
[HTTP-Client][handleHeaderResponse] RX: 'X-Powered-By: Undertow/1
'
[HTTP-Client][handleHeaderResponse] RX: 'Keep-Alive: timeout=5, max=100
'
[HTTP-Client][handleHeaderResponse] RX: 'Connection: Keep-Alive
'
[HTTP-Client][handleHeaderResponse] RX: 'Transfer-Encoding: chunked
'
[HTTP-Client][handleHeaderResponse] RX: 'Content-Type: text/xml
'
[HTTP-Client][handleHeaderResponse] RX: '
'
[HTTP-Client][handleHeaderResponse] code: 200
[HTTP-Client][handleHeaderResponse] Transfer-Encoding: chunked
[ENTS]: HTTP_CODE: 200
[HTTP-Client] read chunk len: 3701
[HTTP-Client][returnError] error(-11): read Timeout
[HTTP-Client][returnError] tcp stop
[ENTS]: Length=1260
<?xml version="1.0" encoding="UTF-8"?>
<Publication_MarketDocument xmlns="urn:iec62325.351:tc57wg16:451-3:publicationdocument:7:0">
	<mRID>d2145fefc7324f33a62e9ce82a4f3a17</mRID>
	<revisionNumber>1</revisionNumber>
	<type>A44</type>
	<sender_MarketParticipant.mRID codingScheme="A01">10X1001A1001A450</sender_MarketParticipant.mRID>
	<sender_MarketParticipant.marketRole.type>A32</sender_MarketParticipant.marketRole.type>
	<receiver_MarketParticipant.mRID codingScheme="A01">10X1001A1001A450</receiver_MarketParticipant.mRID>
	<receiver_MarketParticipant.marketRole.type>A33</receiver_MarketParticipant.marketRole.type>
	<createdDateTime>2023-02-27T17:17:22Z</createdDateTime>
	<period.timeInterval>
		<start>2023-02-26T23:00Z</start>
		<end>2023-02-27T23:00Z</end>
	</period.timeInterval>
	<TimeSeries>
		<mRID>1</mRID>
		<businessType>A62</businessType>
		<in_Domain.mRID codingScheme="A01">10Y1001A1001A46L</in_Domain.mRID>
		<out_Domain.mRID codingScheme="A01">10Y1001A1001A46L</out_Domain.mRID>
		<currency_Unit.name>EUR</currency_Unit.name>
		<price_Measure_Unit.name>MWH</price_Measure_Unit.name>
		<curveType>A01</curveType>
			<Period>
				<timeInterval>
					<start>2023-02-26T23:00Z</start>
					<end>2023-02-27T23:00Z</end>
				</timeInterval>
			

 			

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions