Auto connecting a nodemcu esp8266 to a secondary failover server

I have setup a local blynk server on my PC and nodemcu is connected to it. What I want do is when pc is off and I’m away, I want the nodemcu to connect to blynk cloud server. I want to write the code such a way that it would get the connection status from the local server and if it’s not connected then it will retry for few seconds and then will try to connect to the cloud server. Is it at all possible? Any help is appreciated :slight_smile:
P.s. My ISP charge a lot for public IP, so port forwarding is not an option for me.

Why not use a DynDNS Service? For basic usecases several are avail for free. Try google …
Btw.: I’m sure you have a public IP assigned by your ISP but it’s not static …

Services like DynDns dosen’t work with my ISP. It does provide a static ip however it is shared among many users. They actually have a carrier grade NAT setup and any user router first connects to a static ip on their NAT and then it gets connected to a shared static ip which in terms connects to the internet. so port forwarding in isp NAT is not an option as the external/public ip is shared. It is a public and static ip but it is SHARED. If someone wish to have their own dedicated static ip then they have to pay lot of rental for that.

Not sure if its possible using code … (may be there are ways )
Apart from that there are few problems to face.

  1. The app need to be switched from local server to cloud. (possible easier way to use dual app function to login 2 accounts cloud and local)
  2. BIGGEER PROBLEM If I am not wrong Blynk does not provide sync between local and cloud server yet.

Actually what I am trying to do is run a timer which will check every few seconds that if the local server is available or not, if it is available then it will connect to that server and if not then it will connect to the cloud. I just need the cloud server for simply controlling relays. I am using two projects one in cloud and one in local and also using parallel space to use both in same device, so that is not issue at present. But what I can’t figure out is the code. I have two different auth token for two projects. And I don’t know if it is possible to see if the local server is available while being connected to the cloud.Because if every time it disconnects from the cloud to check the availability of the local that wouldn’t be acceptable.

@roudra

  1. you can use the same token in both the projects without an issue if one server is being connected to.
  2. Look up connection management and you’ll see how to manage the Blynk connection.
  3. In the reconnect, you could try the local server say ‘n’ times and if that fails, try connecting to the cloud.