Spark Server: CryptoStream transform error

This morning I flashed the latest system firmware for the Photon and setup Local Could (Spark Server) on a new machine. The Photon breaths cyan however it is outputting this message:

mac:spark-server user$ node main.js
Loading user EMAIL_ADDRESS
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Starting server, listening on 8080
static class init!
found DEVICE_ID
found DEVICE_ID
Loading server key from default_key.pem
set server key
server public key is: -----BEGIN PUBLIC KEY-----
PUBLIC_KEY
-----END PUBLIC KEY-----

Your server IP address is: 192.168.1.22
server started { host: ‘localhost’, port: 5683 }
Connection from: ::ffff:192.168.1.62, connId: 1
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
> on ready { coreID: ‘DEVICE_ID’,
> ip: ‘::ffff:192.168.1.62’,
> product_id: 6,
> firmware_version: 65535,
> cache_key: ‘_0’ }
> Core online!
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 2
routeMessage got a NULL coap message { coreID: ‘DEVICE_ID’ }
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 3
routeMessage got a NULL coap message { coreID: ‘DEVICE_ID’ }
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 3
routeMessage got a NULL coap message { coreID: ‘DEVICE_ID’ }
CryptoStream transform error Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
Coap Error: Error: Invalid CoAP version. Expected 1, got: 0
routeMessage got a NULL coap message { coreID: ‘DEVICE_ID’ }

It appears that my Photon is connected but I’m not sure about these other errors. Has anyone seen this?

Hi @AshtonJ,

Make sure you’re not using Node 0.12, I think you need a version of Node 0.10.xx. There is also a pending Pull request for the spark-protocol project that fixes an handshake issue with the Photon.

Thanks!
David

Is Node v0.10 still a requirement? It is pretty old now… I get this error when starting using Node v0.10: “Caught exception: Error: /home/janus/spark-server-master/node_modules/ursa/build/Release/ursaNative.node: undefined symbol: node_module_register{}”

Hi @janus,

Keep in mind if you upgrade node you might need to reinstall / recompile the dependencies. I know the ursa (crypto) module had issues for a while with a specific version, but I haven’t had the chance to check the local server recently to see what version it’s compatible with. I think we’ll do a push early next year to make sure we’re current with the latest version of Node.

Thanks!
David

Well, here we are, months later.

I’d love to be able to use these devices. Still getting this crap with a new, clean install:

Connection from: ::ffff:172.20.1.252, connId: 37
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
on ready { coreID: ‘1b002abcdef123456789’,
ip: ‘::ffff:172.20.1.252’,
product_id: 6,
firmware_version: 65535,
cache_key: ‘_36’ }
Core online!
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 0
routeMessage got a NULL coap message { coreID: ‘1b002abcdef123456789’ }
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
Coap Error: Error: Unknown message code: 151
routeMessage got a NULL coap message { coreID: ‘1b002abcdef123456789’ }
CryptoStream transform error TypeError: Cannot read property ‘length’ of null
Coap Error: Error: Invalid CoAP version. Expected 1, got: 0
routeMessage got a NULL coap message { coreID: ‘1b002abcdef123456789’ }
CryptoStream transform error Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
Coap Error: Error: Unknown message code: 246
routeMessage got a NULL coap message { coreID: ‘1b002abcdef123456789’ }
onSocketData called, but no data sent.
1: Core disconnected: socket close false { coreID: ‘1b002abcdef123456789’,
cache_key: ‘_36’,
duration: 25.007 }
Session ended for _36

Suggestions?

I have solved the following way using NVM to manage older versions of node.js.

It’s important to rebuild the dependences of spark-server after using an older node.js version.

$ node --version
v0.12.1
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
$ . ~/.nvm/nvm.sh
$ nvm install 0.10
$ nvm use 0.10
$ cd spark-server
$ rm -rf node_modules
$ npm install
$ node main.js

After this you can use the latest version of particle-cli 1.8.1x using the 0.12.x version of node:

$ nvm exec 0.12 particle xxxxxxxxxxx

or (in another terminal window)

$ nvm use 0.12
$ particle xxxxxxxxxxx

The same apply to the spark-server/main.js that can be launched with:

nvm exec 0.10 node main.js

Has this been fixed yet? I’m getting this error, but I’m brand new to this kind of thing and could be doing something wrong.

It has not