Photon & Local Cloud (spark-server)

My two Photons arrived! I have to run the Local Cloud at work, since our firewall refuses to open up the CoAP port. My Core has connected to the local cloud since I set it up in 12/2014. However, setting up and connecting a Photon yields this message from the server:

Handshake failed:  plaintext was the wrong size: 214

Diving into Handshake.js (in \spark-server\js\node_modules\spark-protocol\lib) I see that the decrypted ‘plaintext’ is expected to contain only a Nonce and CoreID - 52 bytes. It appears that these two elements are in there, with a lot of baggage tacked onto the end. Commenting out the length check allows the connection to succeed.
Did I miss an update? ‘Handshake.js’ doesn’t appear to be part of the spark-server repo.
(Comment - I see this is being discussed here: on GitHub )


Hi @dwfick,

It looks like the local server hasn’t been updated to support the changes to the handshake for the photon. I’m opening a ticket for this here:

I’ve assigned this to myself, and I’ll try to commit a patch for this this week. :slight_smile:


1 Like

Thanks David! Do you guys know when we can get our hands on the full spark-server code?

Looks like there are still a few files/directories missing in the repo.


EDIT: I found it locally and just did a diff of the changes. Will you add them to the repo at some point?

+1 to getting this patched for Photons.
Glad I found this, I was going completely down the wrong track and losing a lot of time on it. Just couldnt get it to connect to the local server. "Handshake failed: plaintext was the wrong size: 214"
I commented out the four lines in Handshake.js as suggested above and it now seems to work as it should. The Photon is now “breathing”. Looking forwards to getting the correct fix.

+1 for me too for Photon support on the local cloud.

@whorner, did you comment lines 361-364 out?

@chuank : yes. Thats the one! All 4 of those lines belong to the same length check.
I just put a simple “//” in front of each of the four lines from 361 to 364.
I imagine the eventual fix would be to add the correct number of additional bytes expected for a Photon into L361. Needs someone who knows exactly what those extra bytes are, how they are defined and how they will behave over time.

Thanks @whorner, after commenting them out the Photons seem to be working fine – variables are visible, and events are getting published on my local cloud.

As reported by others, there are no more OTA firmware upgrades possible – hope that will come soon. I am very impressed with the fast DFU firmware flashing on the Photons!

@Dave, @nexxy (from another relevant post re:spark-server), while particle-server is being worked on, an indication on whether (and when) the following issues will be addressed will be very helpful:

  • subscribing to local cloud events are still limited to the global event firehose – subscribing to events on an individual device is still not possible (i.e. /v1/devices/dev_id/events does not work)
  • OTA firmware upgrades (via particle-cli) for Photons – with more folks attempting to run the local cloud with their new Photons delivered, might this be addressed soon?
  • clarification on public/private events
  • node 0.12.x support?

Hey All!

I did write / submit a quick pull request to the spark-protocol project that fixes the handshake for the photon on the local cloud ( ), my hope is that it’ll be merged in soon and a new npm version will be deployed, spark-server dependencies updated, etc.

I think right now @nexxy is focusing on the CLI, but I’m guessing the local server will get some love in the near future. I’d love to make sure there are open issues for these on the repo, and group them into a milestone so we can set some expectations, etc.



Hi Guys,

I have couple of proton which i want to connect to local cloud.
Which Tutorial i can use to install local cloud on my Raspberry pi, I Tried several but with out any luck.

Thanks for your help.