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

Blynk server disconecting


#1

My problem is that after some time blynk server disconnects. Then if i run the script again it works normally. So i setup the script to run every 10min in crontab but im gating strange behavior. When i touch the buttons its triggered multiple times with delays. Its like multiple servers where running. When i start the script just ones it work normally. The script is the basic one. Im using RPi.


var Blynk = require('blynk-library');
var Gpio = require('onoff').Gpio;
var AUTH = 'xxx';
var blynk = new Blynk.Blynk(AUTH);



#2

what happens if you just run the blynk client ?


#3

I don’t understand the question? Do you mean the client on the phone?


#4

Your initial post seems confusing… what little code you provided references Blynk’s Cloud Server, but then things you say almost sound like you are trying to run a Local Server. Blynk client is another was of saying the sketch that does whatever work you programmed it to do (AKA the sketch that is uploaded to Arduino and ESP when using those devices), as opposed to Blynk’s Local version of server, which can also run on the same RPi as the RPi is capable of multitasking.

Which brings another question… have you confirmed that with all your crontab activations that you are not in fact starting up multiple copies of the same client sketch?


#5

Im not running a local server. Thats the cloud server.

Crontab enty:
@*/8 * * * * node /home/pi/cloudserverscript.js

Yes i think that the problem is that the server is running multiple times but i don’t know how to set it up so it would restart every 8min and close the previous session. Sometimes its disconnect automatically for no reason. The internet is ok. So if i run it every 8min its ok but i have the problem described above.


#6

If you are not running a server then it is NOT running “multiple” times :stuck_out_tongue:

However your client script may be another story… have you ran top or htop to see if there are multiple instances running?

Not enough details. Please show whole script, what version RPi, Ethernet or WiFi, are you running the latest version of the NodeJS library, have you tried any other Blynk scripts, or hardware devices (Arduino, ESP, etc)… and so on.


#7

Post this so we can see… we can’t help much if you dont display it.
Im with Gunner, your post is unclear.

btw, the blynk client is a single command after installing blynk… you launch it by typing #blynk-client


#8

Ok. you were right. There are multiple instances of the client running at the same time. So after a while when i send a command the weird behavior starts. But also after that all except one client remain running. How can i correct my code so that before another client is started the old one gets killed? The code is below. Im using RPi 2 B, nodeJS is the latest.

Crontab entry is:


*/8 * * * * node /home/pi/projekti/vrata.js

vrata.js


var Blynk = require('blynk-library');
var Gpio = require('onoff').Gpio;
var AUTH = 'xxx';
var blynk = new Blynk.Blynk(AUTH);


#9

step1 : remove the cronjob
step2 : post your js script, the full thing (remove your auth token), so everyone can look at it.

maybe see if some areas of your code need documenting ? a small intro to your script on what it does and what your trying to accomplish would be helpfull. the community is really good at helping troubleshoot if you give them your full code.


#10

This is the full script. Im using just the basic client and controlling directly the GPIO-s on the Pi. For what i need it does the job. The only problem i have is that after same time the client gets disconnected. No changes in hardware, no internet , lan loss. Before i had only the auto start the script on reboot set in crontab.
I hade a full script but there was a problem that the Relays conected to the pie were trigered at boot of the script using virtual pins. So i ended up using the direct GPIO control.


#11

You seem to be missing a few parts :wink: and since we can’t see exactly what you are using, and you are having “weird behavior”, there must be something off with either your script or something else in your RPi setup.

I have NodeJS scripts running for weeks at a time without issues.

That is generally fixed by using sync at boot to coordinate with last used settings.


#12

What parts are missing from my script? It is working, not perfectly but…
I know about the sync function but i want things simple. Im a beginner in coding so more staff gets things complicated and usually this is not good.


#13

OK, I guess I am more used to using virtual pins, thus a bit more code :slight_smile:

Which is the whole concept of asking for assistance… and thus the recommendation to learn a bit of code and get better results. Simpler is not always better. I have always found using virtual pins and alternate GPIO libraries (like pigpio) much more stable & reliable then onoff’s direct App-GPIO manipulation.


#14

I say, look at #4 in this step. It really is the easiest, most simple way to get your project up and running using gpio pins. Stop using your js script… for now.

https://docs.blynk.cc/#hardware-set-ups-raspberry-pi


#15

Can you tell me whats the difference between the code in #4 step and mine. Its the same.


#16

Search today’s posts for “8441” for your fix.