Photon 2: "spark/status offline" every few minutes

Using a Photon 2, in the console I'm seeing the "spark/status offline" and "spark/status online" every few minutes. The impact is that user commands time out.

I thought this might be due to my network quality but my WiFi signal is in the 80-90% range. And I still get these dropouts when I reconfigure the Photon 2 to use my phone's WiFi hot spot (signal strength/signal quality 95/93%) I am testing with a Particle WiFi 2.4GHz antenna (ANT-FLXV2) which is not certified for Photon 2 (I have ordered the P2 antenna). However, I get the same results when I select antenna INT_INTERNAL.

Should I be using Particle.keepAlive() for a Photon 2? In the doc, the introduction for keepAlive() says: "On all Gen 3 devices (Argon, Boron, B-Series SoM, Tracker) and Gen 2 cellular devices:" which sounds like it doesn't apply to Photon 2.

However, when I use keepAlive(), changing the keep alive value from 1 minute to 10 minutes changes the rate of dropping offline. This suggests it has an effect on the Photon 2 but perhaps it's some secondary effect.

edit: I verified these dropouts also occur when my firmware is not running. They're visible in the console right after I reconfig the device with setup.particle.io and configure the Wifi connection, but before flashing my firmware.

What tools should I use to debug this?

I've updated the device OS (5.8.0) and I didn't see anything I could use in this similar thread. Photon goes offline – online every ten minutes - #2 by peekay123

thank you!

Setting the keep alive does make a difference on the P2/Photon 2. Your LAN's router (or hotspot) will keep the temporary port forwarding channel for data from the cloud back to the device alive for a period of time before deleting the port forwarding. At that point, the cloud will no longer be able to communicate with the device, the next keep-alive will cause an offline and online event (usually), however the device will breathe cyan the whole time because the device does not know it can't be seen from the cloud.

Reducing the keep-alive helps if the router's port forward deletion is shorter than the default keep-alive. The keep-alive packets keep the router from deleting the port forwarding so the cloud connection stays up continuously.

1 Like

thank you Rick!

reducing the keep-alive from 60 to 30 seconds worked in my case.

1 Like