BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

[SOLVED] Blynk (Local Server) disconnects after my internet goes down


#1

hello

I don’t know if this is the right place to ask this, but is there any way to make blynk restart ? because every time my internet goes down blynk gets disconnected and never connect again only if I do it manually

Thanks


#2

What hardware do you use?


#3

And do you mean a project or a local server ?


#4

I use Raspberry Pi 3, and yes my project on my server gets disconnected if my internet goes down. and I have to restart it manually. Is there anyway to restart it automatically when the internet comes back up ?


#5

Could you please clarify what exactly is gets disconnected? App, hardware, server?


#6

my blynk library you know? the one that I start on my raspberry with my auth token.


#7

His project goes down when power goes off, he has to restart his script.
I suggest you use @reboot in crontab or /etc/init.d
these will make you script run at startup


#8

I said when my internet goes down…not my electricity…I already have it on startup
the project stops when my INTERNET goes down. and I have to start it manually or restart the Raspberry
how come am I not clear enough…


#9

Same thing then, use crontab to restart your project every 30 min or so.


#10

And talking about internet, this is info that you just could have googled you know.


#11

you’re a funny kid :smiley: I was expecting something else not a silly crontab or /etc/init.d config. but seems like this community is not very wise. anyway thanks…


#12

Well maybe you should come up with your own solution then. Your problem is not rocket science, if you don’t like mine you should use google. I heard it works very well.


#13

Your original question was vague and presumptive that Bynk is the problem. Perhaps if you were a lot more detailed on exactly what YOU think is wrong… what YOU have tried to do to resolve it, and how YOU have come to YOUR conclusion that Blynk is responsible… then US wise old ones might not have to resort to guesswork, conjecture, or failing that, disinterest :wink:

Blynk does not control your Local Server’s ability to communicate or connect to the internet (or your router that hands out the required IP), If the internet is there, and the Local Server (not project or library - those are different things) is running (you know, via those silly crontab or /etc/init.d config options), then Blynk awaits App connection, simple.

So if your router is not providing a new IP or your RPi3 is not requesting one, then you should Google that solution. If however Blynk’s Local Server stopped running after your internet mysteriously “goes down”, then follow @Dema323’ s advice and set your Linux commands to autostart the server.js as necessary.


#14

After thinking about this… if you are also running a client script on the same RPi as your server, then that also needs to be set to autorun in crontab or /etc/init.d

Although if both (Server & Client) are on same hardware, then the internet is not the issue (except to access the app) but your router may have other issues handling local network duties, due to whatever brings the internet down…

Basically guessing again… you really need to supply more details :stuck_out_tongue_winking_eye:


#15

as I told you the internet is the problem because the blynk project disconnects and nevers starts again when I unplug my internet cable from the router, anyway thanks for the help I will find a way


#16

Well, the project is what is running on the App (but stored on the server), so yes, it needs the internet link to the Server, unless your phone is also connected to your WiFi LAN side, in which case it should keep on working just fine.


#17

Alright i will make one more suggestion ( im trying to help so don’t hate on me if its not what your looking for).
Try something like this:

ping -c4 your_router_ip_here > /dev/null

if [ $? != 0 ]
then
sudo /path to your script here
fi
This will notice when your internet is down and will run your script when it is able to ping to your router. You could replace the IP with another ip like google’s ip or something.But when it is able to ping it will know internet is up and will start your script


#18

and store this script in /usr/local/bin/


#19

great idea I will try that when I will get home


#20

Below a routine to connect and sychronise Bruni after desconnection try it

bool isFirstConnect = true; // variable declared

//= ====reconnect to blynk and a synchronise

BLYNK_CONNECTED()
{
  if (isFirstConnect)
  {
    Blynk.syncAll();
    isFirstConnect = false;
  }
}