Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blynk-ws nodes stuck after wifi reconnects on raspberry pi #37

Open
AnandJhaveri opened this issue Jun 10, 2022 · 19 comments
Open

blynk-ws nodes stuck after wifi reconnects on raspberry pi #37

AnandJhaveri opened this issue Jun 10, 2022 · 19 comments

Comments

@AnandJhaveri
Copy link

My system hardware/software:
Node-RED version: v2.2.2 running on a RPi 2B.
Blynk legacy running on iOS 14

I have a simple Blynk project with one push button connected to virtual pin 0 (V0).

I am sending status of the V0 virtual pin on my Blynk (legacy) ios app to a NR flow. It is working fine and I can see the pin status (0 or 1) on the debug node on NR.

The Wi-Fi in my house keeps dropping. When the Wi-Fi drops and then returns, the RPi reconnects to the Wi-Fi and comes back online.

However, at this point, I am facing the following problems:

  1. The Blynk ios app says that Blynk if offline.
  2. If I try to inject data to a Blynk node in my NR flow, nothing happens.

If I then invoke 'Restart Flows' from the NR menu, both the above problems get resolved. i.e.

  1. The Blynk ios app is now online
  2. The inject data works and I can see the output in the debug node.

Please could you help to resolve this issue.

Thanks and regards,
Anand Jhaveri.

@Peterkn2001
Copy link

Is this with a local Blynk server, or the Blynk cloud servers?

If it’s the latter then do you realise that the cloud servers will be shut down in December, and that the Legacy apps will be removed from the app/play stores at the end of this month?

Pete.

@AnandJhaveri
Copy link
Author

It's with the Blynk cloud servers.

I did not realize that they are being shut so thank you for this warning.

What do you suggest I do to deal with this situation?

I have two home automation projects that are in production and using the Blynk cloud servers.

I am currently prototyping the architecture suggested by you, using Blynk UI, Node-Red flows, MQTT and ESP32. That's when I ran into the issue where the NR Blynk nodes stopped responding after the RPi WiFi dropped and reconnected.

So, I also need to understand why the NR Blynk nodes stop working when the RPi wifi drops and then re-connects.

Your help in both these matter would be invaluable.

Regards
Anand.

@Peterkn2001
Copy link

Retirement announcement…
https://blynk.io/blog/what-will-happen-to-the-legacy-blynk-platform

I’ve never experienced the issue you’ve described, so not sure what the cause is. I guess that opening a console session and doing a node-red-stop then node-red-start followed by forcing the failure by causing the WiFi issue may give some clues.

I’d suggest moving to the new Blynk IoT product and the new Node-Red contrib.
Some info here…
https://community.blynk.cc/t/my-home-automation-projects-built-with-mqtt-and-node-red/29045/12?u=peteknight

Also, it might be worth upgrading your Pi, as the 2b is getting a bit old now.

Pete.

@AnandJhaveri
Copy link
Author

AnandJhaveri commented Jun 11, 2022 via email

@Peterkn2001
Copy link

Can I install a local Blynk server to run the legacy Blynk after it is
expired?

I wouldn't recommend it. The Legacy app will disappear from the App/Play store at the end of this month, and although you'll be able to sideload the Android version in future it will never be updated and will eventually become incompatible with the Android OS version that you are wanting to run. if you use iOS then life will be even harder, as you'll need to jailbreak your devices and still suffer from the issue of future incompatibility.
Also, the local server code will never be updated to maintain compatibility with future Java versions or to fix vulnerabilities.

My first project is very tightly integrated with legacy Blynk

If, as you've said, you've gone down the MQTT route then migration to Blynk IoT will be far easier.
Did you read the link I provided about how I've handled that migration?

Pete.

@AnandJhaveri
Copy link
Author

I have glimpsed through your long article. I will read it in some depth next week to fully understand it. I have understood the gist of it and built a prototype using the bylnk-ws (legacy) node on NodeRed, Mosquitto (both running on the RPi) and an ESP32.

It all works well and I am now ready to take the next step and try it out using the new Blynk IoT product and the new Node-Red contrib.

However, I remain concerned that (more specifically), the blynk-ws nodes on NR don't recover until I physically press the 'Restart Flows' menu on NR after rebooting my router, which causes wifi on RPi to drop and then reconnect, once the router has rebooted.

I have some concerns when trying to port my application to the new Blynk IoT product.

  1. How does one move a table across? I don't see a table widget in the new Blynk IoT.
  2. Are there other incompatibilities that I should know about, before starting this major project? Is there an FAQ or a document from Blynk that explains how to do such a port?

Thanks once again for all your help.

Anand.

@Peterkn2001
Copy link

How does one move a table across? I don't see a table widget in the new Blynk IoT.

There is no table widget in IoT (yet). You could use Terminal, but that lacks data persistence when the app is closed. A workaround would be to store the data in Node-Red and push it to the terminal on a button push, or use multiple labelled value widgets (or a single labelled value widget with linefeeds to give multiple lines if this is allowed).
Otherwise you could use events instead.

The rest of your question is answered in the forum post, part of which links back to other issues here.

I remain concerned that (more specifically), the blynk-ws nodes on NR don't recover until I physically press the 'Restart Flows' menu on NR after rebooting my router, which causes wifi on RPi to drop and then reconnect, once the router has rebooted.

Did you try my suggestion of observing the Node-Red console info?

Pete.

@AnandJhaveri
Copy link
Author

Did you try my suggestion of observing the Node-Red console info?

I'm very new to NR so don't quite know how to do this? Could you point me to a link or explain how to do this please?

Anand.

@AnandJhaveri
Copy link
Author

Did you try my suggestion of observing the Node-Red console info?

The problem seems to only with the blynk-ws nodes. The rest of the nodes are fine after the router reboot.

Anand.

@Peterkn2001
Copy link

I'm very new to NR so don't quite know how to do this? Could you point me to a link or explain how to do this please?

Are you SSHing to your Pi from a PC, and using PuTTY or similar (my preferred approach), or are your monitor, keyboard and mouse plugged directly into your Pi?

Pete.

@AnandJhaveri
Copy link
Author

AnandJhaveri commented Jun 11, 2022 via email

@Peterkn2001
Copy link

Okay, so open a PuTTY session and log-in.

Then, as I said earlier, type "node-red-stop" then "node-red-start".

You'll then see some debug info as messages are transferred between Node-Red and the Blynk server.
Exactly what you see will be dictated by which options you check in this dialog box for the Configuration Node(s)...

image

Now force a WiFi disconnection and re-connect then see what the messages show about re-establishing the connection and what errors are reported.

When you issue the node-red-start command it will also tell you which version of Node.JS
Node-Red version 2.x.x. requires node.JS version 12.x, although 14.x is recommended. Your Pi 2B is am ARMv6 device, so I guess you might not be able to upgrade to version 12.x, which may be the cause of your problem.

Pete.

@AnandJhaveri
Copy link
Author

Thanks Pete.

I have now got some results from the console log and can share them with you. I hope it might help to narrow the problem.

In summary:
Blynk-ws starts pinging during router reboot
After the router completes the reboot, the MQTT server comes back online with no problem
The Blynk-ws stops pinging and starts sending messages
However, these messages don't reach the Blynk app
Also, the Blynk app continues to report being offline
The, about 15 minutes later, it closes the websocket and reconnects
Once this is done, all is normal.

So, while the issue does to seem to resolve itself, it takes about 15 mins after router reboot which is too long a wait. So, would be great if we can find a solution to this specific issue now.

Details
These are the versions details taken from the log
node-red-start

12 Jun 10:00:23 - [info] Node-RED version: v2.2.2
12 Jun 10:00:23 - [info] Node.js  version: v14.19.3
12 Jun 10:00:23 - [info] Linux 5.15.32-v7+ arm LE

So, the node.js version seems ok.

Here is the output before and after the router reboot
image

What this seems to show is that blynk-ws is able to communicate with the server as the ping (during the wifi outage) has been replaced by the normal messages.

However the following problem continues:

  1. When injecting into a blynk 'sync' node, there is no output on the debug node nor on the blynk app
  2. When pressing a button on the blynk app, we get 'Blynk offline' message on the app.

Here is my flow for your reference:
image

Here is my Blynk screen:
image

15 mins later, here is the console log screen
image

This resolves the issues, but it takes approximately 15 mins from the time the router reboots, to resolve itself.

Can we find a faster solution?

Regards,
Anand.

@Peterkn2001
Copy link

I think that’s a question for @gablau, but TBH I’d focus on migrating to Blynk IoT rather than worrying about issues with the Legacy product.

Pete.

@AnandJhaveri
Copy link
Author

Pete,

Yes, agreed. I will start work on the new IoT.

I have now the Spain project part of your link.

One question:
You are using a 433Mhz Kerui button to transmit to the 433 to MQTT gateway.

image

On the gateway end, what 433 receiver are you using and how are you decoding the processing the signal?

Anand.

@gablau
Copy link
Owner

gablau commented Jun 12, 2022

Hello everybody,
thanks a lot to Pete for this triage.
Anand which version of this library are you using? make sure it's the last one.
Let me know

Regards
Gabriele

@Peterkn2001
Copy link

Virtually any 433MHz receiver that uses a crystal, like this...

image

will work fine. Avoid the ones without a crystal (one that look like this...)

image

I use the RCSwitch library to decode the signals then send the result to Node-Red as an MQTT message.

You can also hack the Sonoff RF Bridge to achieve the same result if you wish.

TBH, this discussion would work better on the Blynk community forum if you're going to diverge from the initial issue that you raised regarding the ws contrib.

Pete.

@AnandJhaveri
Copy link
Author

Anand which version of this library are you using? make sure it's the last one. Let me know

Hi Gabriele,

Many thanks for you reply.

I'm new to NodeRed so not sure how to check the version of the library I've installed.

Please could you help me on how to find the version?

Regards,
Anand.

@AnandJhaveri
Copy link
Author

Anand which version of this library are you using? make sure it's the last one. Let me know

Ok, I figured it out.

image

I'm using the latest version....1.0.7

Anand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants