Problem reading channel. HTTP error code -304

13 ビュー (過去 30 日間)
Amanj Abdollah Zadeh
Amanj Abdollah Zadeh 2020 年 9 月 7 日
コメント済み: Niels 2025 年 2 月 19 日
when i want to read data from thingspeak, i get the below messege :
Problem reading channel. HTTP error code -304
how can i solve this?
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 7 日
Vinod
Vinod 2020 年 9 月 8 日
How are you reading the data from your ThingSpeak channel?
  • A HTML page using the ThingSpeak API and Javascript?
  • MATLAB code using thingSpeakRead?
  • From an embedded device?
  • Something else?

サインインしてコメントする。

回答 (2 件)

Christopher Stapels
Christopher Stapels 2020 年 9 月 8 日
移動済み: Christopher Stapels 2024 年 1 月 5 日
The negative errors are from the communication library, not standard HTTP responses. From the ThingSpeak communication library readme, -304 is Timeout waiting for server to respond. This seems to either be a network issue, or you are sending an incomplete message to ThingSpeak. Are you using one of the standard examples form the library or your own code?

Niels
Niels 2025 年 2 月 18 日
The same problem appeared here when accessing a university server, except I was writing not reading a field. I solved this by trying to write the field up to 10 times during 5 seconds. Now I always get a success with error code 200. I guess the same idea would work for reading a field. Why it works, I've got no clue.
int returnCode;
for (int i=0; i<10; ++i) {
returnCode = ThingSpeak.writeField(channelId, field, value, pw);
if (returnCode == 200) break;
delay(500);
}
Serial.println("writeField " + String(field) + " " + String(value,2) + " " + String(returnCode));
  2 件のコメント
Vinod
Vinod 2025 年 2 月 18 日
The suggestion I would make is to apply some sort of (exponential?) backoff to the delay in the loop. You don't want to inadvertantly trigger a DoS attack from your device. A simple backoff might be:
delay(500 + i*(i+100));
Niels
Niels 2025 年 2 月 19 日
That's neat, thanks. The danger of triggering a DoS attack detector did not occur to me. Thinking more about the problem, I guess that the university IoT server has gotten quite busy due to a proliferation of connected things. So, every time that I try to connect through it to ThingSpeak, there is a probability of it being busy and denying my request. Then, it is simply a matter of trying repeatedly until by chance I get through.

サインインしてコメントする。

コミュニティ

その他の回答  ThingSpeak コミュニティ

カテゴリ

Help Center および File ExchangeRead Data from Channel についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by