Reconnect supported ? | 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
Reconnect supported ?
No permission to create posts
January 24, 2019
8:24 am
Avatar
sundeep

Silver
Members
Forum Posts: 5
Member Since:
December 22, 2018
sp_UserOfflineSmall Offline

Does the arduino libabry support reconnection? i mean if a connection is lost due to some reason and you are getting a -301 error, what is the correct way to handle it and reconnect ?

January 25, 2019
9:11 am
Avatar
JasonW

MathWorks
Members
Forum Posts: 54
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

The library doesn't handle network connections. So if the connection drops the library isn't going do anything about it, it just reports the failed attempt. It is up to the application code to establish and monitor the network connection. The examples that are included with the Arduino ThingSpeak libraries show how to do that.
For example, take a look at this https://github.com/mathworks/thingspeak-arduino/blob/master/examples/ArduinoMKR1000/WriteSingleField/WriteSingleField.ino

January 26, 2019
12:06 am
Avatar
sundeep

Silver
Members
Forum Posts: 5
Member Since:
December 22, 2018
sp_UserOfflineSmall Offline

JasonW said

The library doesn't handle network connections. So if the connection drops the library isn't going do anything about it, it just reports the failed attempt. It is up to the application code to establish and monitor the network connection. The examples that are included with the Arduino ThingSpeak libraries show how to do that.
For example, take a look at this https://github.com/mathworks/thingspeak-arduino/blob/master/examples/ArduinoMKR1000/WriteSingleField/WriteSingleField.in  

Hi Jason, presume you mean the part about wifi reconnets, my code has that already - and wifi reconnections are handled properly. The issue i am facing regularly now is that after some time (say a few hours) i keep getting -301 errors while updating a thinkspeak channel.

January 31, 2019
11:39 am
Avatar
JasonW

MathWorks
Members
Forum Posts: 54
Member Since:
October 21, 2016
sp_UserOfflineSmall Offline

A -301 happens when a TCP connection to api.thingspeak.com fails. Our servers are definitely up and running, so there is something going on that prevents your hardware from making the connection. This is not a common error to see. Is it possible you are running out of RAM?

Since a retry is not handled automatically by the library, you'll need to catch the -301 in your code and do something about it. Assuming you have code to detect and handle a WiFi reconnection, you could try adding this to the loop() which manually forces the WiFi disconnection:

if(statusCode == -301){
WiFi.disconnect();
}
February 1, 2019
7:01 am
Avatar
sundeep

Silver
Members
Forum Posts: 5
Member Since:
December 22, 2018
sp_UserOfflineSmall Offline

JasonW said
Is it possible you are running out of RAM?
you could try adding this to the loop() which manually forces the WiFi disconnection:

if(statusCode == -301){
WiFi.disconnect();
}

  

Its possible, subsequent investigation revealed that the esp module was unreachable and not attempting to re-connect (based on serial debug output). So i added an esp.reboot() line after a -301 detection. Its been working fine since.

Thanks for your guidance !!!

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
14 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:

briskpanda, Dejw0089, Yassine Ben Salah, anis, 43994554AKS, suda

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457