tzapu / node-red-contrib-blynk-websockets

MIT License
35 stars 12 forks source link

help with configuring Blynk for websockets #1

Open bretskee opened 8 years ago

bretskee commented 8 years ago

Hi tzapu,

can you help me with configuring local server for websockets. I have installed your new nodes and dont know how to set up the server / Pi and then what do I put in the connection dialog in the node setup. Sorry, bit of a newbie at websockets.

tzapu commented 8 years ago

hi, it s quite simple, but not standard, should of mentioned it somewhere so, first of all, you need to get the latest server jar from blynk see setup and install intructions here http://docs.blynk.cc/#blynk-server-how-to-run-local-blynk-server then you need to have a server.properties file in which you need to setup the proper ports, they all need to be available or blynk server won t start. the ports you are interested of knowing for websockets are

#web sockets ssl port
ssl.websocket.port=8081
#web sockets plain tco port
tcp.websocket.port=8082

see whole config file here (the link in docs is broken) https://github.com/blynkkk/blynk-server/blob/master/server/core/src/main/resources/server.properties

and after all that is done, connect your mobile app to the server (create account and login) then in node red you add the url like so ws://127.0.0.1:8082/websocket for insecure or for secured connenction if you have a ssl cert wss://127.0.0.1:8081/websocket

obviously repalce the ip and port with yours give it a go cheers

bretskee commented 8 years ago

Thanks so much. Seems to work a treat. Love to see your support for LCD like your other great work. I am testing it in a mixed environment with the standard blynk nodes to see if it has solved my disconnect problem.

tzapu commented 8 years ago

perfect, you probably can write to the lcd node as it is currently anyway, if this sorts disconnection issues for everyone, i will scrap the old one and work on this, i simply have more control this way, although with more work, but still, i can check when/how something happens

bretskee commented 8 years ago

disconnect happened before my eyes this afternoon. happened to be sitting in front of the node-red gui for my project. debug window started to error. connected status on each node changed to 'ERROR' and eventually 'disconnected'. I have a screen shot if you would like me to email it to you. good news is that I was using both Blynk protocol and new websocket nodes simultaneously. websocket nodes did not error nor disconnect and continued to work. unfortunately as discussed above, i do not have a websockets LCD and that part of my project did not recover.

tzapu commented 8 years ago

hi, that is good to hear (the good part, not the bad part) i think since news are generally good, i ll start to move everything onto this, including lcd

Toshibass commented 8 years ago

One question .. When you move to web sockets model will that only work for local server or blynk cloud as well ?

tzapu commented 8 years ago

for now only local server, the blynk guys said it will only be a few weeks before adding websockets to cloud.blynk.cc so when that happens that will work as well

ghost commented 8 years ago

Thanks heaps for this! I was about to open a new issue.

The WS button responds about twice as fast as the old TCP one!!

BTW the ports were already open, there was no need for a server.properties file

Toshibass commented 8 years ago

Hi tzapu

I had some spare time today so thought I would try blynk for websockets so I followed the 2nd top post as far as "connect your mobile app to the server (create account and login)" now I am a bit worried here , I have node-red-contrib-blink working via cloud and since recent node-red update v0.13.3 the mqtt problem I was having appears to be rectified so all in all its pretty stable, and I dont want to loose my existing blink app

In other words I want to run node-red-contrib-blink and node-red-contrib-blink-websockets at the same time ... if I open the blink app on my iphone and create account and login will this screw up my existing node-red-contrib-blink app stuff ? or is it possible to have 2 separate blink apps on my phone 1 for node-red-contrib-blink cloud and another for node-red-contrib-blink-websockets for local server ?

Thanks for any help

tzapu commented 8 years ago

hi,

you can use both versions of the plugin at the same time in node red.

unfortunately you can not have 2 apps on your phone, so you need to logout/login if you want to switch from local to cloud one

tzapu commented 8 years ago

hi, hold the press, i just asked the blynk guys, and there might be websockets on the live version as well

i ll report back

tzapu commented 8 years ago

so, great news, websockets support is in the live version as well i could only make the non ssl version work by using this url ws://cloud.blynk.cc:8082/ws

so, you can start replacing your old nodes with new nodes seamlessly @Toshibass :)

let me know how it works

Toshibass commented 8 years ago

yeh great news, I tried replacing some blynk nodes with blynk_ws nodes for a sonoff unit and it works fine via the blynk cloud (as you say with ws://cloud.blynk.cc:8082/websocket non ssl mode) shame ssl doesn't work wss://127.0.0.1:8081/websocket I am now going to replace some more stuff and I will report back on how it goes.

Before you "reported back" I started to try and find some info on certificates, am I right in thinking this is purely needed for local server and has nothing to do with blynk cloud stuff ?

tzapu commented 8 years ago

for every ssl connection a ssl cert would be needed for local server to support ssl you d need a ssl cert ( i use one from start ssl, seems fine)

for cloud.blynk.cc they need to install a cert, nothing you can do really

cheers

Toshibass commented 8 years ago

So do you think cloud ssl doesnt work just because they didn't install a cert to enable it ?

tzapu commented 8 years ago

i know so, i spoke to them on slack, they have a team setup and it s quite easy/fast to get answers from them now. they did not have time to provision it yet, but i m thankful at least they added it

Toshibass commented 8 years ago

Hi Tzapu I can confirm ws://cloud.blynk.cc:8082/ws is working without fault since the last 3 days I have 3 blynk projects on the blynk ios app, I converted 1 of my projects to ws (incidentally the remaining 2 projects that are still on node-red-contrib-blynk also worked faultlessly since recent node-red update v0.13.3 although I believe a contributing factor to this is that I have each project on a separate pi instead of using 1 pi for all the projects) Just going back to my original question as I am still keen to try a local server for some of my flows, I understand now I need to logout of my current blynk app and create a new account to use with the local server however I am still a bit hesitant, so do I just need to enter a different email address and password for the local server then depending on which email address I use I will be able to log into my cloud setup or the local server.?

Also is there some better explanation how to setup ssl on the local server anywhere ?

I am guessing the server.propertied file needs modifying - these lines ....

provide either full path to files either use '.' for specifying current directory. For instance "./myfile.crt"

server.ssl.cert= server.ssl.key= server.ssl.key.pass= client.ssl.cert= client.ssl.key=

But the instructions "See how to generate self-signed certificates here" link just appears to lead back to the same web page, I cannot find any instruction on how to generate the required files ?