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

Does the P2/Photon 2 send keep-alives while sleeping in SystemSleepMode::STOP mode? Typical sleep time is 2 minutes.

I'm getting the same messages, but they only occur when my device wakes from sleep.

Wi-Fi devices cannot keep the cloud connection alive while sleeping, so you will always get an offline-online pair for every sleep-wake cycle.

1 Like

Thanks @rickkas7

I assume these sleep config modes were intended for this purpose, but are not implemented?

.network(NETWORK_INTERFACE_WIFI_AP)
.network(NETWORK_INTERFACE_WIFI_STA)

The constants do work for network interfaces, but not for sleep. I'm not even sure the RTL872x can do it - Wi-Fi and BLE are implemented on the main MCU, not a separate dedicated controller that could be kept running in sleep mode.

2 Likes