Correct Websocket Address for Blynk Server?

I deliberately changed my auth token…

I will attempt to DM it to you now.

Apologies. Forgot to answer your entire message.

I am definitely using the Blynk cloud service. I haven’t got as far as building my own server yet

I don’t run any Blynk specific code on my MCU. As you say, I use MQTT to communicate between Node-Red and the MCU, but this isn’t necessary for testing.

Without any MCU involved, put a button widget on you app and link it to the project/Auth Code that you’re using in Blynk and assign it to V0.
Set-up a Blynk Write node and a debug node in Node-Red like the one i showed above and deploy the project. The Blynk node should say “Connected” and when you press the widget button you should get a 0 and/or 1 in the debug window.

I’ve just seen your full auth token and it’s correct, When I modify the URL it gives the project details and when I put it into a new connection in my Node-Red setup it connects to your project. If you send some data to V0 is should see it in my debug screen.

What happens if you ping blynk-cloud.com from your Node-Red server?

Pete.

sending some 1s and zeros now…

it’s on pin v0

temperature is coming in every second on v6…

Yep, this is what I see…

Pete.

how frustrating…

why can’t I get that :frowning:

What happens when you ping blynk-cloud.com from your Node-Red server?

Pete.

it responds to pings

I have to admit that I’m no UNIX expert - in fact I know very little. I’m looking for differences between your setup and mine.
I’m running an earlier version of Node-Red, but a later version of Node.js (v6.13.0 compared to v4.8.7)
Maybe time to upgrad Node.js?

Welcome to Node-RED

22 Feb 10:26:54 - [info] Node-RED version: v0.17.5
22 Feb 10:26:54 - [info] Node.js version: v6.13.0
22 Feb 10:26:54 - [info] Linux 4.9.59-v7+ arm LE
22 Feb 10:26:56 - [info] Loading palette nodes

You can also put Node-Red in verbose debug mode (Ive never done this) using:

Debug
Use the verbose -v flag when starting Node-Red to get more information or use node-red-log and enable log on Configuration Node as needed

Pete.

1 Like

I have updated my version of node… no idea how it was out of date as I only built this server yesterday… must have followed some instructions that specified the actual version to install…

anyway… still no luck. still the same error message…

does your setup look like this?

1_Flow1_EventNode

Just wondering if I have configured something incorrectly?

Trev

Yes, that’s how mine looks, except I don’t have any of the logging boxes checked and nothing in Pin Logging:
image
image

Pete.

I have just setup Node-Red on my local windows 10 PC and with the exact settings I have on my AWS Linux machine it works!

So, it has to be something relating to the box or network…

Okay, that’s good news - I guess!
I use a Raspberry Pi 3 as my Node-Red and Mosquitto server and that works very well. I find it extremely reliable and zero maintenance; which is good as I don’t have much of a clue with the UNIX/Linux stuff.

I actually used Peter Scargill’s script from his website:
https://tech.scargill.net/?s=the+script
The only issue with this is that it installs the old websockets node by default, but it’s easy enough to remove this via the Pallet Manager and install the ws version instead.
Pete’s “Big Timer” node is great if you want to do any timed stuff.

I’m actually in the process of building a Node-Red/ESP8266/Blynk weather station for our holiday home in Spain.
Most of the hard work is done, it just needs the hardware installed on the roof and a few wrinkles ironing out.
The core of my system is a Nextion touch screen which controls the heating and cooling systems depending on readings from the internal temperature sensors, but it also displays data from the outdoor temperature, humidity and pressure sensors.

Blynk shows more detailed outdoor weather data including wind speed, wind direction and rainfall, and I plan to add a raindrop detector (so we know to bring the laundry in) and a light intensity sensor.

For me, using MQTT is a great way to collect data from these various sensors and to push it out to Blynk as required.
I’m aso using Amazon Alexa integration in Node-Red to give me voice control and feedback of temperature. It’s great to be lying in bed in the morning and say “Alexa, what’s the temperature in the lounge” and when the answer is “15 degrees” I can say “Alexa, turn the lounge heating on” and “Alexa, set an alarm 10 minutes”.

Blynk is really handy for remotely monitoring everything, and for checking the temperature at home and turning the heating or cooling on before you get home so that everything nice and comfortable.

Feel free to PM me if you want to pick my brains or kick ideas around.

Pete.

1 Like

That’s amazing… pretty much what I am attempting to do!

1 Like

Hi Trev,
I recently discovered a bug on the ‘node-red-contrib-blynk-ws’ library, indeed the CONNECT_REDIRECT command is a valid command not a SERVER_EXCEPTION. Apparently the server is asking us to change the address / port where to connect.

See https://github.com/blynkkk/blynk-server/blob/master/server/tcp-hardware-server/src/main/java/cc/blynk/server/hardware/handlers/hardware/auth/HardwareLoginHandler.java line 150

It would be interesting to do further tests … do you still have the aws server? Would you do some tests with an updated library if I send it to you?

@Dmitriy Could you explain how a client should behave when the CONNECT_REDIRECT command is received? could you give me an example of such logs? it is not easy to recreate this problem.

regards
Gabriele

1 Like

Hardware sends login command. In case token for login command is not found on the server that is resolved via geo dns request (by hostname) than server returns CONNECT_REDIRECT command in format serverIP:port. Where server:port is server which hosts your user data.

As workaround you may directly connect to the server that returned in CONNECT_REDIRECT instead of “blynk-cloud.com” host.

node-red-contrib-blynk-ws seems to be outdated and doesn’t support CONNECT_REDIRECT

2 Likes

Hi,

Yes, I still have my AWS box running. it’s running my MQTT mosquito service. Which works great.

I have just got back from the pub so typing with one eye open at the moment.

Would be more than happy to try and help with AWS.

Where should I start?

@Dmitriy Yes geoDNS! Thank you!

Step to reproduce bug:
nslookup blynk-cloud.com 8.8.8.8 <-- my current DNS
Nome: blynk-cloud.com
Address: 139.59.206.133 <-- blynk server with my data

nslookup blynk-cloud.com 202.46.32.187 <-- a chinese DNS
Nome: blynk-cloud.com
Address: 45.55.96.146 <-- chinese blynk server without my data

Inside the blynk configuration node in node-red change the address of the server with the Chinese one (ex. ws://45.55.96.146/websockets) now at login we get this:

8 Mar 23:45:50 - [info] [blynk-ws-client:Blynk - Test] Start connection: ws://45.55.96.146/websockets
8 Mar 23:45:50 - [info] [blynk-ws-client:Blynk - Test] SEND -> Cmd: LOGIN Id: 1 Data: "\u0002\u0000\u0001\u0000 ***************************7dcf7"
8 Mar 23:45:50 - [info] [blynk-ws-client:Blynk - Test] RECV <- Cmd: CONNECT_REDIRECT, Id: 1, len: 19, data: "139.59.206.133\u00008080"

Of course we need to change servers to connect with: ws://139.59.206.133:8080/websockets
For now it should be changed by hand, in the next release of the node-red library everything will happen automatically.

@trevordaniel2
Thanks for the availability, but I managed to reproduce the bug. Now I’ll try to correct it.
Meanwhile, if you want you can resolve blynk-cloud.com with nslookup on the server where it works and then manually copy the ip address on the AWS server, it should work.

regards
Gabriele

1 Like

New release 0.4.0 of node-red-contrib-blynk-ws library!

Added

Changed

Fixed

  • Invalid HW cmd: “pm” see iusse #3
  • Protocol Log on message received and retrive right command body

regards
Gabriele

3 Likes

YAY! - It works!

I am connectified!

Capture

1 Like