Suddenly appearing problems reading data by ESP | ESP Wi-Fi | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Suddenly appearing problems reading data by ESP
No permission to create posts
June 27, 2019
7:09 am
Avatar
weinerg
New Member
Members
Forum Posts: 3
Member Since:
June 27, 2019
sp_UserOfflineSmall Offline

Hello,
since yesterday I get an error when reading data from ThingSpeak by ESP.

I am using an ESP-01 with the latest Arduino IDE and the latest ThingSpeak library.
Till (June 26, 2019 14:30 UTC everything worked without problems.
But now I suddenly get "ERR_BAD_RESPONSE -303 // Unable to parse response".

Interestingly the same ESP is able to write data to the same channel. I already have rebooted my router, in order to avoid network problems at home.

The part of arduino code that doesn't work anymore is quit simple and I wonder what could be wrong?

int tsCmd;
int tsReadStatus;

WiFiClient clientTS;
ThingSpeak.begin(clientTS);

tsCmd = ThingSpeak.readIntField(myChannelNumber, TS_FIELD_CMD, myReadAPIKey);
tsReadStatus = ThingSpeak.getLastReadStatus();
if (tsReadStatus != OK_SUCCESS)
{
...
}
else
{
...
}

Does anyone know if there has been changed anything at ThingSpeak?

Many thanks for any hint.

June 27, 2019
9:13 am
Avatar
No3x
New Member
Members
Forum Posts: 3
Member Since:
June 27, 2019
sp_UserOfflineSmall Offline

I do have the same issue.
The last entry on the channel was on 2019-06-26T14:39:51.000Z +- 10min (I check the the date of the last entry before writing a new value).
I used the ThingSpeak library for arduino 1.3.0. Then I updated to 1.5.0 but the same issue.
I query
https://api.thingspeak.com/channels/channelid/fields/1/last_data_age
In the browser the response is fine.
My code is

bool shouldSendNewValue() {
String urlSuffix = String("/fields/") + String(1) + String("/last_data_age");
syslog.logf(LOG_DEBUG, "ChannelNr: %s", thingspeakChannelNr );
String lastDataAgeResponse = ThingSpeak.readRaw( atoi(thingspeakChannelNr), urlSuffix, thingspeakReadAPIKey );
int statusCode = ThingSpeak.getLastReadStatus();
if( 200 == statusCode ) {
unsigned int lastDataAge_s = lastDataAgeResponse.toInt();
syslog.logf(LOG_INFO, "[TS] lastDataAge_s: %u", lastDataAge_s);
return lastDataAge_s >= THINGSPEAK_UPDATE_INT_S;
} else {
syslog.logf(LOG_ERR, "[TS] Failed to read from channel. Cause %d", statusCode);
return false;
}
}

The log for 1.5.0 is
[TS] Failed to read from channel. Cause -303
for 1.3.0 a constant response of 5
[TS] lastDataAge_s: 5

June 27, 2019
10:04 am
Avatar
weinerg
New Member
Members
Forum Posts: 3
Member Since:
June 27, 2019
sp_UserOfflineSmall Offline

Hello,

I now just checked the tcp response of ThingSpeak.

For me it seems that "Content-Length: " is missing and therefore the library answers with ERR_BAD_RESPONSE.

I try to make a workaround for the 1.5.0 library.

June 27, 2019
10:05 am
Avatar
danlorek

Silver
Members
Forum Posts: 6
Member Since:
January 4, 2019
sp_UserOfflineSmall Offline

I wonder if this is similar to the issue that I am experiencing that was reported here:
https://community.thingspeak.com/forum/thingspeak-api/free-license-limitation/#p9118

Can you view a chart on the channel for the field you are trying to retrieve data for on thingspeak.com?

June 27, 2019
9:54 pm
Avatar
va3atw

Silver
Members
Forum Posts: 5
Member Since:
April 21, 2019
sp_UserOfflineSmall Offline

If you can figure out the work around for 1.5, I would love to hear it - I am having the same problem too....

June 27, 2019
11:59 pm
Avatar
hrubisek
New Member
Members
Forum Posts: 1
Member Since:
June 27, 2019
sp_UserOfflineSmall Offline

Hello, I have the same problem. I use Wemos D1 mini pro 16MB. ThingSpeak 1.5.0 Library. Writing without problems, reading doesn't work, returns -303. What is your ESP version? I have 2.4.2.

June 28, 2019
2:05 am
Avatar
weinerg
New Member
Members
Forum Posts: 3
Member Since:
June 27, 2019
sp_UserOfflineSmall Offline

Hello,

yesterday I made a workaround for the ThingSpeak.h file and it works for me.

My workaround is based on the function getHTTPResponse, but unfortunataly this function is also used by the write functions.
Only changeing the origional function leads to errors in sending to ThingSpeak.
So I made a copy of the function and renamed it to getHTTPResponse1.
Within the readRaw function I then use the getHTTPResponse1 insetad of getHTTPResponse.

Below the new function.
Unfortunately the CR LF aren't displayed correctly in my post.
So please change CR to "backslash and r" and LF to" backslash and n".

int getHTTPResponse1(String & response)
{

// make sure all of the HTTP request is pushed out of the buffer before looking for a response
this->client->flush();

long timeoutTime = millis() + TIMEOUT_MS_SERVERRESPONSE;

while(this->client-> available() timeoutTime){
return ERR_TIMEOUT;
}
}

if(!this->client->find(const_cast("HTTP/1.1")))
{
#ifdef PRINT_HTTP
Serial.println("ERROR: Didn't find HTTP/1.1");
#endif
return ERR_BAD_RESPONSE; // Couldn't parse response (didn't find HTTP/1.1)
}
int status = this->client->parseInt();
#ifdef PRINT_HTTP
Serial.print("Got Status of ");Serial.println(status);
#endif
if(status != OK_SUCCESS)
{
return status;
}
// find header end
if(!this->client->find(const_cast("CRLFCRLF")))
{
return ERR_BAD_RESPONSE;
}
// find start of content
if(!this->client->find(const_cast("CRLF")))
{
return ERR_BAD_RESPONSE;
}
// parse content
timeoutTime = millis() + TIMEOUT_MS_SERVERRESPONSE;
String tempString1 = String("");
char y1 = 0;
while(y1 != 'CR'){
while(this->client->available() timeoutTime){
return ERR_TIMEOUT;
}
}
y1 = client->read();
if (y1 != 'CR') {
tempString1.concat(y1);
}
}
response = tempString1;
return status;

};

June 28, 2019
5:56 am
Avatar
foivaras
New Member
Members
Forum Posts: 2
Member Since:
June 28, 2019
sp_UserOfflineSmall Offline

Intentionally or not, they removed the "content-length" header from the http response. The thingspeak library expects this header to correctly parse the response,
therefore they managed to break their library.

@ Thingpeak, was that an intentional change or a bug that will be fixed?
If it was intentional, are you going to update the official arduino thingspeak library accordingly?

Thanks.

June 28, 2019
9:59 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Thanks for all the feedback. We are looking into the issue and will post here as soon as we are sure of what happened.

June 28, 2019
6:07 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

You may be able to temporarily fix the issue by backing up to the previous version of the ThingSpeak communication library. It is only the latest version that uses the "content-length" header. We will continue to report on the issue here and let you know when it is resolved.

June 29, 2019
7:04 am
Avatar
No3x
New Member
Members
Forum Posts: 3
Member Since:
June 27, 2019
sp_UserOfflineSmall Offline

I can't confirm 1.4.3 as workaround.
for 1.4.3 a constant response of 6
[TS] lastDataAge_s: 6
The last data age currently is 246113 (s) (queried with webbrowser). Don't know how it's parsed but it goes wrong without content-length, too.

June 29, 2019
9:46 am
Avatar
DanRoid

Silver
Members
Forum Posts: 5
Member Since:
June 28, 2019
sp_UserOfflineSmall Offline

cstapels said

You may be able to temporarily fix the issue by backing up to the previous version of the ThingSpeak communication library. It is only the latest version that uses the "content-length" header. We will continue to report on the issue here and let you know when it is resolved.  

Using version 1.4.x of the library does not fix the problem. No error code is returned but the incorrect value for the data is retrieved.

June 29, 2019
11:06 am
Avatar
va3atw

Silver
Members
Forum Posts: 5
Member Since:
April 21, 2019
sp_UserOfflineSmall Offline

Using 1.4.x only returns a value of 5 on my end.

June 29, 2019
11:09 am
Avatar
va3atw

Silver
Members
Forum Posts: 5
Member Since:
April 21, 2019
sp_UserOfflineSmall Offline

Good News!

I flipped it back to the 1.5.0 library - It's working now!!!!!!!!

June 29, 2019
11:33 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 861
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

We just released a fix to the problem (~10:59 AM EST). It should not depend on the library version, and we recommend that you use the latest version of the library. Thanks va3atw for confirming. Anybody else on this thread, please confirm that it is working now if you can. Thank you for your help and patience.

June 29, 2019
1:12 pm
Avatar
DanRoid

Silver
Members
Forum Posts: 5
Member Since:
June 28, 2019
sp_UserOfflineSmall Offline

cstapels said

We just released a fix to the problem (~10:59 AM EST). It should not depend on the library version, and we recommend that you use the latest version of the library. Thanks va3atw for confirming. Anybody else on this thread, please confirm that it is working now if you can. Thank you for your help and patience.  

Confirmed, working correctly now. Many thanks.

June 29, 2019
5:13 pm
Avatar
No3x
New Member
Members
Forum Posts: 3
Member Since:
June 27, 2019
sp_UserOfflineSmall Offline

Works with 1.4.3 and 1.5.0 again.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

khanhNguyen_CT, susyburr, quijano__, meosuckhoe, briskpanda, Dejw0089

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457