Problems of local cloud/spark-server for handling high frequency requests from device

Hello bbs, currently we are trying to set up local cloud for particle device, which are supposed to processing large number of requests per second (>100).

We have updated the local cloud to v4 nodejs. Most of features works great, however there is a small CryptoStream bug popping out randomly (weirdly coming out for every 100~200 request). It is not fatal for low frequency data acquisition, however it is really bad for high frequency data acquisition meaning it will simply break the pip and everything stops for 1~2 seconds.

The error message is:

CryptoStream transform error Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt

And after carefully looking into code, I noticed the exception occurred in following code snippet in
/node_modules/spark-protocol/lib/CryptoStream.js

The code snippet can be referred as below:

try {
    var cipher = this.getCipher(callback);
    cipher.write(chunk);
    cipher.end();  // exception occurred here
    cipher = null;
    if (!this.encrypt) {
        this.vi = new Buffer(16);
        chunk.copy(this.vi, 0, 0, 16);
    }
} catch (ex) {
    // error occurred!  - bad-decrypt
}

Is it because of the server issues, the firmware or even the bugs in openssl.

For reference the openssl package i installed is:

OpenSSL 1.0.2g 1 Mar 2016

The node version is

node v4.2.6

The npm version is:

npm v3.5.2

Any suggestions will be appreciated!

Maybe this community version would work better (but i did not test it): https://github.com/Brewskey/spark-server

1 Like

Appreciate your hints! After looking into code in detail, I think there are quite huge modifications compared to original spark-server. I believed it will save many times for us to fix this tiny bugs instead of migrating whole systems. I have some thought on the reasons of my bugs, but sadly don’t know how to fix it :frowning:

I posted in another threads since it is more relevant. Would you mind helping me looking into it? any suggestions are welcome! Cheers!
Here is the link, see last post :smile: