Correct Websocket Address for Blynk Server?

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