vshymanskyy / blynk-library-js

Blynk library for JS. Works with Browsers, Node.js, Espruino.
https://blynk.io/
MIT License
215 stars 67 forks source link

Application crashed: Cannot read property 'authorized' of null #41

Open Alexey-Tsarev opened 6 years ago

Alexey-Tsarev commented 6 years ago

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

tuloski commented 6 years ago

See: https://github.com/vshymanskyy/blynk-library-js/issues/40