Coder Social home page Coder Social logo

vshymanskyy / blynk-library-js Goto Github PK

View Code? Open in Web Editor NEW
213.0 24.0 67.0 917 KB

Blynk library for JS. Works with Browsers, Node.js, Espruino.

Home Page: https://blynk.io/

License: MIT License

JavaScript 97.81% Makefile 2.19%
blynk espruino iot-platform iot smartphone smartphone-interaction npm-package

blynk-library-js's Introduction

SWUbanner

vshymanskyy's GitHub stats

Publications

Recognition

blynk-library-js's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blynk-library-js's Issues

handle disconnect from server

Hi, is there a way in the js library of handling a disconnect from the blynk server or checking the connection status in order to retry the connection if failed?
Thanks

Fix to avoid disconnects when writing while not ready

Under certain scenarios I get repeating connect/disconnect sequence. I get the same on Mint and on Raspberry Pi. Blynk-library downloaded by npm in last week.

Example guaranteed crash code:

`
#!/usr/bin/env nodejs
var token = 'a82b38d etc - use your own! ';
var Blynk = require("blynk-library");
var blynk = new Blynk.Blynk(token); // ssl default

// Blinking LED widget at APP screen.
var V15 = new blynk.VirtualPin(15);
var ledval = 0; // brightness
setInterval(function(){
// we put a LED widget on phone APP at V15. Let's blink it on phone.
ledval = 255-ledval;
V15.write(ledval);
}, 200); // 5/sec ie rather fast - first write is before conn is settled.

`
It seems if a virtual write is pushed out while socket connection is not stable, then the blynk process in nodejs immediately disconnects from the server. If the writes keep coming, the server is repeatedly disconnected, in a useless loop.

My solution is to change this line in blynk.js:
532 this.sendRsp(msg_type, msg_id, data.length, data);
into:
if ((typeof this.timerHb) === 'object' && this.timerHb != null) {this.sendRsp(msg_type, msg_id, data.length, data)};

Now, writes attempted during socket connection unavailability are simply dumped.
(timerHb is heartbeat/ping callback, and it seems to make a workable "flag" for indicating when conn is fully up.)

Brian

blynk-cloud SSL certificate error

I cannot connect to the blynk server using the secure connection. The SSL authorization fails with a DEPTH_ZERO_SELF_SIGNED_CERT error. I understand that this is most likely not a problem of this project, but since I could not find anything online, I thought to raise the issue here. Well, at least your examples currently fail on two machines I tested them on.

This is what I get if I run the Usage Example from your main README file:

Connecting to: blynk-cloud.com 8441
SSL authorization...
events.js:159
      throw err;
      ^

Error: Uncaught, unspecified "error" event. (DEPTH_ZERO_SELF_SIGNED_CERT)
    at emit (events.js:157:17)
    at Blynk.error (/Users/trident/git/gitlab/blynk.agent/node_modules/blynk-library/blynk.js:571:8)
    at null.<anonymous> (/Users/trident/git/gitlab/blynk.agent/node_modules/blynk-library/blynk.js:534:48)
    at emitOne (events.js:90:13)
    at emit (events.js:182:7)
    at TLSSocket.<anonymous> (/Users/trident/git/gitlab/blynk.agent/node_modules/blynk-library/blynk-node.js:197:16)
    at emitOne (events.js:90:13)
    at TLSSocket.emit (events.js:182:7)
    at emitErrorNT (net.js:1250:8)
    at _combinedTickCallback (node.js:377:13)

not connecting/reconnecting issues

hi
when i m using a wrong token i get into a re-connection loop stating that connection is authorized. Is there an event that we could use for when it fails and disable the loop maybe, or handle it in a more straightforward manner?
Cheers

Connecting to SSL: cloud.blynk.cc 8441
Connected, authorized
Connecting to SSL: cloud.blynk.cc 8441
Connected, authorized
Connecting to SSL: cloud.blynk.cc 8441
Connected, authorized
...
Connecting to SSL: cloud.blynk.cc 8441
Connected, authorized
Connecting to SSL: cloud.blynk.cc 8441
Connected, authorized
Connecting to SSL: cloud.blynk.cc 8441

How handle array of param on Write?

Hi
My code

var v2 = new blynk.VirtualPin(2);      //table
var v20 = new blynk.VirtualPin(20);`     //webhook
v2.on('write', function(param) {
  if (param[0] == "select")
  {
    var rowID = param[1];
    v20.write(rowID);
  }
});

is it right?

Uncaught error on disconnect

This is what I keep getting sometimes:

Error: Uncaught, unspecified "error" event. (ECONNRESET) at Blynk.emit (events.js:164:17) at Blynk.error (node_modules/blynk-library/blynk.js:622:8) at exports.SslClient.<anonymous> (node_modules/blynk-library/blynk.js:585:48) at emitOne (events.js:96:13) at exports.SslClient.emit (events.js:189:7) at TLSSocket.<anonymous> (node_modules/blynk-library/blynk-node.js:223:16) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:189:7) at emitErrorNT (net.js:1280:8) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

npm-install

npm-install installs blynk-library 0.0.19", not "0.0.21", !

No longer connects

The port of blynk-cloud.com has changed from 8441 to 9443.

I have changed the port in my local copy in blynk-node.js:
self.port = options.port || 9443;

And it seems to be working ok.

You might want to make the fix and update in npm.

Cheers. :)

SSL not authorized since yesterday...

Hi,

The lib's been running like a charm for 2 years but it doesn't connect anymore since yesterday...

Script running on node v12.19.1 on a raspberry Pi 3B (Raspberry Pi OS).

Any suggestion ??

Here's the error message.

Connecting to: blynk-cloud.com 443
SSL authorization...
SSL not authorized

Regards,

Damien

Connecting to local blynk server fails with DEPTH_ZERO_SELF_SIGNED_CERT

I am running a local blynk server (0.11.4) on a Raspberry Pi with a self-signed SSL certificate, as instructed in the wiki.

When trying to connect through blynk-library-js (0.0.23), I get the following error:

OnOff mode
Connecting to SSL: 192.168.1.55 8443
Error DEPTH_ZERO_SELF_SIGNED_CERT

The exact code I am using to connect is:

var BlynkLib = require('/usr/local/lib/node_modules/blynk-library');
var options = {addr:"192.168.1.55",port:8443}
var AUTH = 'XXXXX';
var blynk = new BlynkLib.Blynk(AUTH, options);

Both the server key and certificate are recognised in the start-up process of the server but I am not sure where to get/put the client certificate? The server log prints this:

16:25:14.272 INFO  - Plain tcp/ip hardware server port 8442.
16:25:31.156 INFO  - SSL hardware port 8441.
16:25:31.289 INFO  - Enabling SSL for application.
16:25:31.293 WARN  - Found server certificates but no client certificate for '/home/pi/blynk-server' path. Using one way ssl.
16:25:31.651 INFO  - Application server port 8443.
16:25:31.725 INFO  - Administration server port 8777.

Thanks

edison

hey there, i am used to running blynk code in arduino environment
Now, i have an intel edison and want to use JS.
in the documentation/instructable you say use npm install -g mraa blynk,
should i ssh into edison first? or can i run this directly from terminal?
thanks

'Blynk_App_Connected' event is not supported?

Per docs.blynk.cc an event should be generated each time the Blynk App, running on mobile phone, is opened. I searched the file blynk.js for all emitted events but could not find anything resembling this functionality. I could not find an example showing this behavior either.

Does this functionality exist for the JavaScript version of Blynk library?

If so, please describe the usage.

If not, please add this as a feature request.

OnOff GPIO read error for Raspberry Pi.

The inbuilt code to read GPIO at Raspberry Pi (using OnOff library) seems broken. The write/gpio output is OK, but read/gpio crashes. (Blynk-library version = as fetched by npm in last week.)

My fix:
in file blynk-node.js, function BoardOnOff, case "dr", alter the line reading
373 self.blynk.sendMsg(MsgType.HW, null, ['dw', values[1], value]);
to remove the parameter null, ie
self.blynk.sendMsg(MsgType.HW, ['dw', values[1], value]);

Now it works fine.

Of course, the blynk/OnOff combination has no support for internal pullup resistors, so I have now gotten used to using rpio library to service my gpio button pins (withblynk virtual pins), and leaving the inbuilt OnOff reads for plain vanilla gpio inputs.

Brian

Add reference documentation on the library

The library does not appear to have any reference documentation. The best one can do is pour through the source and try and decode what it means. This issue asks for resources to be spent documenting the library so that it can be easier consumed by programmers.

Easier way to declare a virtualpin in nodejs?

As normal, I declare a Virtualpin like your example: var v1 = new blynk.VirtualPin(1);
If I have "some" virtualpin, it's fine, but in case of many pins, about 40 - 50 pin? Is there any way to more quick and easier to declare a virtual pin instead of write 40 - 50 lines ? I know this is personal question, but hope you can help me.

digitalWrite GPIO pins with code

Hi, I know the library auto-detects GPIO read/write without having to write code, but I would like to set a GPIO pin on a raspberry pi high/low using code. Is there a way to do it? @vshymanskyy

Lots of connect and disconnect, SSL not authorized, and crash

I get this very often (once a day at least):

Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 SSL authorization... SSL authorization... Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 Connecting to: blynk-cloud.com 8441 SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL not authorized SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL authorization... SSL not authorized SSL authorization... SSL not authorized SSL authorization... SSL not authorized

until it crashes....

Espruino doesn't seems to work

Hi,

When I want to read from blynk it's not working.
This is my code :

pin=NodeMCU.D2;

var wifi = require("Wifi");
var dht = require("DHT22").connect(pin);
var Blynk = require('http://tiny.cc/blynk-js');
var AUTH = 'ddff00000c';

var temp = null;

function onInit() {
  wifi.setHostname("antoine-espruino");

  wifi.connect("club", {password:"fdfd4422fd"}, function(err){
    if (err) throw err;
        console.log("WiFi connected.", wifi.getIP() );
        blynkInit();
  });

  wifi.stopAP();
  wifi.save();
}


function blynkInit() {
  
  var blynk = new Blynk.Blynk(AUTH);

  var v9 = new blynk.VirtualPin(9);
  var v1 = new blynk.VirtualPin(1);

      
  v1.on('write', function(param) {
    console.log('V1:', param);
  });


  v9.on('read', function() {
    v9.write(temp);
    console.log('readed ',temp);
  });

  blynk.on('connect', function() { console.log("Blynk ready.");});
  
  blynk.on('disconnect', function() { console.log("DISCONNECT"); });
}

save();

Doesn't work in docker

⌁41% [:~/Play/rpi/blynk] $ docker run --rm -it --name blink --privileged blink bash
root@7c75d93ca691:/# blynk.js xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
OnOff mode
Connecting to SSL: cloud.blynk.cc 8441
Connected, authorized
Blynk ready.
/usr/local/lib/node_modules/blynk-library/blynk-node.js:303
            this.blynk.sendMsg(MsgType.HW, null, ['dw', values[1], value]);
                ^
TypeError: Cannot read property 'blynk' of undefined
    at /usr/local/lib/node_modules/blynk-library/blynk-node.js:303:17
    at /node_modules/onoff/onoff.js:151:7
    at FSReqWrap.wrapper [as oncomplete] (fs.js:527:17)

Dockerfile:

FROM resin/rpi-raspbian:jessie

RUN echo "deb http://apt.adafruit.com/raspbian/ jessie main" >> /etc/apt/sources.list && \
    apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes node && \
    apt-get clean

RUN apt-get install -y python
RUN apt-get install -y build-essential
RUN npm install epoll && \
    npm install onoff

RUN npm install -g blynk-library

CMD ["blynk.js", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"]

Ran with command:

docker build -t blink .
docker run --rm -it --name blink --privileged blink

VM the host system is sleeping but still connect

My Blynk server is hosting on VM (CoreOS).
When the host system (Windows) sleeping, the client still connects.

I am using TCP client.

let b = new blynk.Blynk(auth, {
  connector: new blynk.TcpClient(options)
})
...

Get Blynk-library-js working on Espruino running natively on ESP8266

There has been a project on the go for a couple of months which is a port of Espruino to native ESP8266 execution and it is progressing well to the point that there are now stable drivers. This issue asks to see if there is interest in testing and collaboration on getting blynk-library-js running directly on Espruino running natively on ESP8266?

If yes, and the developers of the Espruino port to ESP8266 can assist, please contact [email protected] or respond to this issue.

Library does not work at all with new version of Blynk (2.0)

I can not get this library to connect at all with Blynk 2.0. I keep getting ETIMEDOUT Errors. I see this library has not been updated since 2019. Are there plans to update it in the near future? I am paying for a Blink subscription and Node.js support was an advertised feature.

Best Regards,
Mike

failed intial connection handling

HI, it seems the lib throws and exception if for instance the port is wrong

12 Oct 18:26:02 - Error: socket hang up
at TLSSocket.onHangUp (_tls_wrap.js:959:21)
at TLSSocket.g (events.js:199:16)
at TLSSocket.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)

expected behavior would be to fail gracefully with an event

cheers

INVALID_TOKEN

JS library doesn't seem to work with Blynk 2.0. I get the INVALID_TOKEN error when trying to connect. Is this a known issue?

TypeError: "options" must be a string or an object, got number instead.

I am getting this error with the provided sample problem

at getOptions (fs.js:50:11)
at fs.readFileSync (fs.js:465:13)
at Array.map (native)
at exports.SslClient.connect (/home/pi/motor/node_modules/blynk-library/blynk-node.js:170:42)
at doConnect (/home/pi/motor/node_modules/blynk-library/blynk.js:546:15)
at Blynk.connect (/home/pi/motor/node_modules/blynk-library/blynk.js:559:5)
at new Blynk (/home/pi/motor/node_modules/blynk-library/blynk.js:385:10)
at Object. (/home/pi/motor/blynk-motor.js:9:13)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)

I looked at the code carefully and it is at this line

if (self.ca) { opts.ca = self.ca.map(fs.readFileSync); }

fs.readFileSync takes options as second parameter, so it can't be used with map.

Application crashed: Cannot read property 'authorized' of null

Log:

[2018-04-25T22:06:21.440Z] Error: ECONNRESET
[2018-04-25T22:06:21.441Z] Error ECONNRESET
[2018-04-25T22:06:26.566Z] Connecting to: blynk-cloud.com 8441
[2018-04-25T22:06:26.635Z] SSL authorization...
[2018-04-25T22:06:26.863Z] Connected
[2018-04-25T22:06:26.925Z] Authorized
[2018-04-25T22:06:26.926Z] Blynk connected
[2018-04-26T00:07:38.203Z] Error: ECONNRESET
[2018-04-26T00:07:38.203Z] Error ECONNRESET
[2018-04-26T00:07:43.328Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T00:07:43.447Z] SSL authorization...
[2018-04-26T00:07:43.606Z] Connected
[2018-04-26T00:07:43.689Z] Authorized
[2018-04-26T00:07:43.689Z] Blynk connected
[2018-04-26T10:27:07.060Z] Error: ECONNRESET
[2018-04-26T10:27:07.061Z] Error ECONNRESET
[2018-04-26T10:27:10.984Z] Error: ERROR
[2018-04-26T10:27:10.984Z] Error undefined
[2018-04-26T10:27:11.199Z] Error: ERROR
[2018-04-26T10:27:11.199Z] Error undefined
[2018-04-26T10:27:12.308Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:27:12.571Z] SSL authorization...
[2018-04-26T10:27:12.707Z] Connected
[2018-04-26T10:27:12.770Z] Authorized
[2018-04-26T10:27:12.770Z] Blynk connected
[2018-04-26T10:27:15.986Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:27:16.050Z] SSL authorization...
[2018-04-26T10:27:16.181Z] Connected
[2018-04-26T10:27:16.201Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:27:16.263Z] SSL authorization...
[2018-04-26T10:27:16.396Z] Connected
[2018-04-26T10:27:16.458Z] Authorized
[2018-04-26T10:27:16.458Z] Blynk connected
[2018-04-26T10:27:25.985Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:27:26.047Z] SSL authorization...
[2018-04-26T10:27:26.177Z] Connected
[2018-04-26T10:27:35.985Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:27:36.050Z] SSL authorization...
[2018-04-26T10:27:36.184Z] Connected
[2018-04-26T10:27:45.985Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:27:46.047Z] SSL authorization...
[2018-04-26T10:27:46.177Z] Connected
[2018-04-26T10:27:56.130Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:27:56.193Z] SSL authorization...
[2018-04-26T10:27:56.324Z] Connected
[2018-04-26T10:28:06.163Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:28:06.226Z] SSL authorization...
[2018-04-26T10:28:06.357Z] Connected
[2018-04-26T10:28:16.164Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:28:16.226Z] SSL authorization...
[2018-04-26T10:28:16.369Z] Connected
[2018-04-26T10:28:26.164Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:28:26.226Z] SSL authorization...
[2018-04-26T10:28:26.356Z] Connected
[2018-04-26T10:28:36.165Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:28:36.230Z] SSL authorization...
[2018-04-26T10:28:36.362Z] Connected
[2018-04-26T10:28:46.166Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:28:46.229Z] SSL authorization...
[2018-04-26T10:28:46.359Z] Connected
[2018-04-26T10:28:56.167Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:28:56.229Z] SSL authorization...
[2018-04-26T10:28:56.363Z] Connected
[2018-04-26T10:29:06.167Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:29:06.231Z] SSL authorization...
[2018-04-26T10:29:06.364Z] Connected
[2018-04-26T10:29:16.168Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:29:16.231Z] SSL authorization...
[2018-04-26T10:29:16.365Z] Connected
[2018-04-26T10:29:26.170Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:29:26.232Z] SSL authorization...
[2018-04-26T10:29:26.363Z] Connected
[2018-04-26T10:29:36.171Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:29:36.233Z] SSL authorization...
[2018-04-26T10:29:36.364Z] Connected
[2018-04-26T10:29:46.172Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:29:46.260Z] SSL authorization...
[2018-04-26T10:29:46.391Z] Connected
[2018-04-26T10:29:56.172Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:29:56.234Z] SSL authorization...
[2018-04-26T10:29:56.365Z] Connected
[2018-04-26T10:30:06.173Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:06.260Z] SSL authorization...
[2018-04-26T10:30:06.631Z] Connected
[2018-04-26T10:30:07.253Z] Error: ECONNRESET
[2018-04-26T10:30:07.254Z] Error ECONNRESET
[2018-04-26T10:30:10.988Z] Error: ERROR
[2018-04-26T10:30:10.988Z] Error undefined
[2018-04-26T10:30:11.202Z] Error: ERROR
[2018-04-26T10:30:11.202Z] Error undefined
[2018-04-26T10:30:12.254Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:12.335Z] SSL authorization...
[2018-04-26T10:30:12.467Z] Connected
[2018-04-26T10:30:12.535Z] Authorized
[2018-04-26T10:30:12.535Z] Blynk connected
[2018-04-26T10:30:15.989Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:16.051Z] SSL authorization...
[2018-04-26T10:30:16.175Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:16.202Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:16.237Z] SSL authorization...
[2018-04-26T10:30:16.264Z] SSL authorization...
[2018-04-26T10:30:16.368Z] SSL not authorized
[2018-04-26T10:30:16.395Z] Connected
[2018-04-26T10:30:16.457Z] Authorized
[2018-04-26T10:30:16.457Z] Blynk connected
[2018-04-26T10:30:25.989Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:26.052Z] SSL authorization...
[2018-04-26T10:30:26.175Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:26.237Z] SSL authorization...
[2018-04-26T10:30:26.368Z] Connected
[2018-04-26T10:30:35.991Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:36.176Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:36.182Z] SSL authorization...
[2018-04-26T10:30:36.242Z] SSL authorization...
[2018-04-26T10:30:36.315Z] SSL not authorized
[2018-04-26T10:30:36.374Z] Connected
[2018-04-26T10:30:45.992Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:46.176Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:46.192Z] SSL authorization...
[2018-04-26T10:30:46.356Z] SSL authorization...
[2018-04-26T10:30:46.524Z] SSL not authorized
[2018-04-26T10:30:46.683Z] Connected
[2018-04-26T10:30:46.848Z] Disconnect blynk
[2018-04-26T10:30:46.849Z] Blynk disconnected
[2018-04-26T10:30:46.849Z] REARMING DISCONNECT
[2018-04-26T10:30:51.849Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:51.912Z] SSL authorization...
[2018-04-26T10:30:52.047Z] Connected
[2018-04-26T10:30:52.109Z] Authorized
[2018-04-26T10:30:52.109Z] Blynk connected
[2018-04-26T10:30:52.109Z] Got Pin write, vPin: 0 (pin index: 0), param: 0 (All pins)
[2018-04-26T10:30:52.109Z] Got Pin write, vPin: 0 (pin index: 0), param: 0 (recursed) (All pins)
[2018-04-26T10:30:52.109Z] Got Pin write, vPin: 1 (pin index: 1), param: 0
[2018-04-26T10:30:52.110Z] Got Pin write, vPin: 2 (pin index: 2), param: 0
[2018-04-26T10:30:52.110Z] Got Pin write, vPin: 3 (pin index: 3), param: 0
[2018-04-26T10:30:52.110Z] Stop timer
[2018-04-26T10:30:52.110Z] Got Elapsed write, vPin: 13, param: Stopped
[2018-04-26T10:30:52.110Z] Got Level write, vPin: 12, param: 0
[2018-04-26T10:30:52.110Z] Syncing
[2018-04-26T10:30:52.172Z] Got Timer write, vPin: 11, param: 1
[2018-04-26T10:30:52.173Z] Got Level write, vPin: 12, param: 0
[2018-04-26T10:30:52.173Z] Got Elapsed write, vPin: 13, param: Stopped
[2018-04-26T10:30:55.993Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:56.055Z] SSL authorization...
[2018-04-26T10:30:56.177Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:30:56.239Z] SSL authorization...
[2018-04-26T10:30:56.371Z] Connected
[2018-04-26T10:31:05.994Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:06.056Z] SSL authorization...
[2018-04-26T10:31:06.178Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:06.241Z] SSL authorization...
[2018-04-26T10:31:06.373Z] Connected
[2018-04-26T10:31:15.994Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:16.056Z] SSL authorization...
[2018-04-26T10:31:16.179Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:16.242Z] SSL authorization...
[2018-04-26T10:31:16.373Z] Connected
[2018-04-26T10:31:25.994Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:26.056Z] SSL authorization...
[2018-04-26T10:31:26.179Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:26.241Z] SSL authorization...
[2018-04-26T10:31:26.373Z] Connected
[2018-04-26T10:31:35.993Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:36.055Z] SSL authorization...
[2018-04-26T10:31:36.180Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:36.243Z] SSL authorization...
[2018-04-26T10:31:36.377Z] Connected
[2018-04-26T10:31:45.994Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:46.181Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:46.197Z] SSL authorization...
[2018-04-26T10:31:46.361Z] SSL authorization...
[2018-04-26T10:31:46.527Z] SSL not authorized
[2018-04-26T10:31:46.688Z] Connected
[2018-04-26T10:31:47.015Z] Error: ECONNRESET
[2018-04-26T10:31:47.015Z] Error ECONNRESET
[2018-04-26T10:31:50.990Z] Error: ERROR
[2018-04-26T10:31:50.990Z] Error undefined
[2018-04-26T10:31:51.202Z] Error: ERROR
[2018-04-26T10:31:51.203Z] Error undefined
[2018-04-26T10:31:52.015Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:52.080Z] SSL authorization...
[2018-04-26T10:31:52.211Z] Connected
[2018-04-26T10:31:52.335Z] Error: ECONNRESET
[2018-04-26T10:31:52.335Z] Error ECONNRESET
[2018-04-26T10:31:52.536Z] Error: ERROR
[2018-04-26T10:31:52.536Z] Error undefined
[2018-04-26T10:31:52.775Z] Error: ERROR
[2018-04-26T10:31:52.776Z] Error undefined
[2018-04-26T10:31:55.991Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:55.995Z] Connecting to: blynk-cloud.com 8441
[2018-04-26T10:31:56.055Z] SSL authorization...
[2018-04-26T10:31:56.057Z] SSL authorization...
[2018-04-26T10:31:56.182Z] Connecting to: blynk-cloud.com 8441
/Users/atsarev/dev/n_lighter/node_modules/blynk-library/blynk-node.js:204
        if (!self.sock.authorized) {
                       ^

TypeError: Cannot read property 'authorized' of null
    at TLSSocket.<anonymous> (/Users/atsarev/dev/n_lighter/node_modules/blynk-library/blynk-node.js:204:24)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket.<anonymous> (_tls_wrap.js:1126:14)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:639:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:469:38)
head -n 210 /Users/atsarev/dev/n_lighter/node_modules/blynk-library/blynk-node.js | tail
      console.log("SSL authorization...");
      opts.socket = sock;
      self.sock = tls.connect(opts, function() {
        if (!self.sock.authorized) {
          console.log('SSL not authorized');
          return;
        }
        console.log('Connected');
        self.sock.setNoDelay(true);
        self.sock.setEncoding('binary');

I think need to check sock variable is not null

'SSL not authorized' when using Let's Encrypt

In blynk-nodejs, SslClient() the default options.certs_path points to server.crt in library and therefore options.ca maps to server.crt used for blynk-cloud.com. To enable SSL authorization via Mozilla CA, the options.ca must be null. I've tried options.certs_path pointing to a empty server.crt file but this returns options.ca === [ <Buffer > ], an empty buffer which evaluates to 'true'.

I have temporarily hard coded opts.ca = null to prevent overriding the Let's Encrypt authorization.

Can this control blynk devices?

As far as I've seen so far it seems to act as a device, being controlled by the app. But can it act as the app controlling a device?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.