Thingspeak 301 Error with NodeMCU (ESP8266) [writing to multiple channels]

Hi I am posting/writing some real time data to multiple fields of multiple channels (4)with help of ESP8266 Wifi Module, but after some time thingspeak returns me 301 error.
I tried with Office Wifi as well Mobile Hotspot the issue persists.
In office we have a static IP based dual band connection.
Please let me know, what to do to remove this error.
I tried reintialising the connection with ThingSpeak.begin(client); whenever this error comes but no help.
Please let me know how to remove the issue , as I am at critical junction of an important project and this is the only roadblock that I have.

 Accepted Answer

Vinod
Vinod on 22 Apr 2022
Edited: Vinod on 22 Apr 2022
I believe this is because of DNS caching somewhere on your end. See this thread for information. Also see this thread, which gets a bit more technical about how often DNS caches are invalidated.
My question to you is - how often are you making these requests? Does powering your device off, waiting at least 60 seconds and powering it back on result in 200 responses that then become 301's within a few seconds? Have you had a chance to check your router config for how long it caches the DNS records, specifically for https://api.thingspeak.com ?
Ways to get the DNS TTL are described here. Please share the TTL number you see for api.thingspeak.com
One of your earlier questions was about MQTT. Did you migrate away from using the MQTT interface to using the REST API? Why?

4 Comments

Hi the TTL values are not a constant entity it changes everytime when we ping , the few values I got were 48 ,35,29.
I'm using the free version so the message to thingspeak is sent every 15 seconds that is giving buffer/delay of 15 channels for each channel .
When the 301 error comes I have to reset the ESP8266 , then it starts functioning normmally but yes as you said after a while it comes again.
I am exploring various possibilites , that's why currently switched to REST API by taking reference from here.
I think you may need to use the method described in this post to for an invalidation of the local cache on the esp8266.
Hey apologies for delayed response I was OOO.
Is there any other way, cuz this is not clear to me.
I have the same issue, after sending between a few hundred and a few thousand messages on 6 fields of the same channel. The board is nodeMCU and I use ThingSpeak library.
On another channel, from the same network (router) I have another ESP8266 with no issue since is there, for more than five years. This one doesn't use the ThingSpeak library.
Both send messages every minute.
Any clue?

Sign in to comment.

More Answers (0)

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on ThingSpeak in Help Center and File Exchange

Products

Release

R2022a

Asked:

on 22 Apr 2022

Commented:

on 25 Sep 2024

Community Treasure Hunt

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

Start Hunting!