How is Photon connecting to Particle

How are the Photon and such connecting to Particle to get the updates and receive calls to functions and variable gets? I’m guessing it’s a pull of some sort over http. Is it a websocket or is it doing making a periodic post/get?

Then how do they publish events? I would guess over the same connection.

I’m a software engineer who’s tinkering with this and will probably present this to my team, so being able to speak on this will be handy and I’m just generally curious as well. There’s so much documentation, I looked around, but didn’t find what I was looking for…

Thanks - Peter

The Photon (and P1) establish a connection to the Particle cloud using the CoAP protocol over TCP on port 5683, outbound. In other words, the bi-directional connection is made from the Photon/P1 to the cloud servers so no port forwarding is required. This connection is kept open continuously.

Both sides are mutually authenticated using RSA public-private key pairs so the cloud knows the device is the correct one, and the device is protected from a rogue cloud.

As part of the authentication process, a session key is generated for encrypting the session. The session itself is encrypted using AES.

One of the advantages of using CoAP instead of MQTT is that all of the device cloud features (publish, subscribe, functions, variables, and OTA firmware flash) are all done over the single CoAP connection.


Awesome, thank you!

Quick comment that I don’t see an advantage to using CoAP. There are a number of OTA via MQTT implementations for ESP32, and subscribe/functions/variables are just effectively RPC calls that are easily instrumented via MQTT topics.

On the flipside, having MQTT instead of CoAP would be a major advantage. It’s the default protocol of the major cloud provider’s implementations of IOT. For power users they could connect their device to their IOT registry and then add your mqtt server and credential information into a particle portal so particle knows where to connect to issue commands and subscribe etc.

That’s the perfect world. It’d also massively reduce processing for Particle.

1 Like