tzapu / node-red-contrib-blynk

Blynk app integration with Node Red
MIT License
17 stars 5 forks source link

Possible to use local server #2

Closed tvillingett closed 8 years ago

tvillingett commented 8 years ago

Can it be changed to use a local server as alternative to the blynk.cc?

tzapu commented 8 years ago

hi, will do that as soon as i have some time

pull requests are more than welcome though :d

tzapu commented 8 years ago

i added support for specifying hostname and port in 0.0.6 but i don t have a local blynk server to test with. could you please test it and report back? also, make sure you don't enter the wrong hostname/port, the blynk lib seems to throw an exception and kill everything

tvillingett commented 8 years ago

I have tried it, and it probably crashed as you warned, because I lost contact with the node-red server. I had to reset the blynk server options in the flow to default by editing the ~/userdir/flows.json and removing the extra options for that instance. The port could be set to default 8442, I understand that it should be the port from "hardware" side.

tvillingett commented 8 years ago

For more info: I added the local server to the already working "cloud-server" in the list of servers in the flow inside node-red.

The blynk.log says: 19:58:18.578 INFO - Initializing mail transport. Username : example@gmail.com. SMTP host : smtp.gmail.com:587 19:58:21.159 INFO - Using data dir '/home/pi/Blynk' 19:58:21.181 DEBUG - Starting reading user DB. 19:58:24.456 DEBUG - Reading user DB finished. 19:58:24.620 DEBUG - hard.socket.idle.timeout = 15 19:58:24.620 INFO - Plain tcp/ip hardware server port 8442. 19:58:24.630 WARN - ATTENTION. Certificate /root/userdir and key /root/userdir paths not v alid. Using embedded certs. This is not secure. Please replace it with your own certs. 19:58:28.448 INFO - SSL hardware port 8441. 19:58:28.482 INFO - Enabling SSL for application. 19:58:28.484 WARN - ATTENTION. Server certificate paths cert : '/root/userdir', key : '/ro ot/userdir' - not valid. Using embedded server certs and one way ssl. This is not secure. P lease replace it with your own certs. 19:58:30.744 DEBUG - app.socket.idle.timeout = 600 19:58:30.745 INFO - Application server port 8443. 19:58:30.769 INFO - Administration server port 8777. 19:59:08.743 TRACE - Incoming LoginMessage{id=2018, command=LoginMessage, length=66, body=' tvillingett@gmail.com KOIY/j8VhvpmOMdzokUzaH6Y9WwnXUQukPowK1oRyTY='} 19:59:08.836 TRACE - Creating unique session for user: {"dashTokens":{"1232933926":"1c82738 821ce4ce69f6d602508ef7302"},"name":"tvillingett@gmail.com","pass":"KOIY/j8VhvpmOMdzokUzaH6Y 9WwnXUQukPowK1oRyTY=","lastModifiedTs":1444677981228,"profile":{"activeDashId":1232933926," dashBoards":[{"id":1232933926,"name":"local blync","timestamp":1444677737,"widgets":[{"type ":"GAUGE","id":1912236079,"x":0,"y":0,"color":-308477697,"width":4,"height":3,"label":"Effe kt","pinType":"VIRTUAL","pin":0,"frequency":0,"min":0,"max":15000,"mappingMode":0}],"boardT ype":"Generic Board","keepScreenOn":false,"isSharedPublic":false,"isActive":false}]}} 19:59:08.836 INFO - tvillingett@gmail.com app joined. 19:59:09.133 TRACE - Incoming LoadProfileMessage{id=13562, command=LoadProfileMessage, leng th=0, body=''} 19:59:09.255 TRACE - Incoming SaveProfileMessage{id=7674, command=SaveProfileMessage, lengt h=298, body='{"dashBoards":[{"id":1232933926,"timestamp":1444677737,"name":"local blync","b oardType":"Generic Board","widgets":[{"id":1912236079,"label":"Effekt","x":0,"y":0,"width": 4,"max":15000,"type":"GAUGE","color":-308477697,"height":3,"pin":0,"mappingMode":0,"pinType ":"VIRTUAL","frequency":0,"min":0}]}]}'} 19:59:10.106 TRACE - Incoming GetTokenMessage{id=18263, command=GetTokenMessage, length=10, body='1232933926'} 19:59:14.958 TRACE - Incoming SaveProfileMessage{id=31706, command=SaveProfileMessage, leng th=298, body='{"dashBoards":[{"id":1232933926,"timestamp":1444677737,"name":"local blync"," boardType":"Generic Board","widgets":[{"id":1912236079,"label":"Effekt","x":0,"y":0,"width" :4,"max":15000,"type":"GAUGE","color":-308477697,"height":3,"pin":0,"mappingMode":0,"pinTyp e":"VIRTUAL","frequency":0,"min":0}]}]}'} 19:59:15.005 TRACE - Incoming ActivateDashboardMessage{id=16307, command=ActivateDashboardM essage, length=10, body='1232933926'} 19:59:15.017 TRACE - Incoming HardwareMessage{id=2441, command=HardwareMessage, length=2, b ody='pm'} 19:59:33.330 ERROR - Input command is invalid. Closing socket. Reason cc.blynk.common.excep tions.UnsupportedCommandException: Command with code 22 not supported message.. Address /12 7.0.0.1:33081 19:59:33.330 ERROR - Input command is invalid. Closing socket. Reason cc.blynk.common.excep tions.UnsupportedCommandException: Command with code 22 not supported message.. Address /12 7.0.0.1:33083 19:59:33.393 TRACE - Hardware channel disconnect. 19:59:33.393 TRACE - Hardware channel disconnect. 20:00:37.940 INFO - Catch shutdown hook. Trying to save users and close threads.

tzapu commented 8 years ago

do you have the node red log as well? i am setting the regular certs on the connection, but maybe it should not be a ssl connection at all on port 8442... for blynk.cc it connects on 8441

looking at the long 8441 ssl, 8442 plain text. try it on 8441 as well, let s see what happens

tzapu commented 8 years ago

i have uploaded a new version that will alow you to connect without ssl. untick the use ssl checkbox and enter your hostname/port

tvillingett commented 8 years ago

ok, I will test it. From the Blynk server on github (https://github.com/blynkkk/blynk-server) it says for default start: "Run the server on default 'hardware port 8442' and default 'application port 8443' (SSL port)"

tzapu commented 8 years ago

hi, are you running on local server yet or still getting errors? cheers

tzapu commented 8 years ago

this should work fine now