Particle.publish() _WITH_ACK flag Timeout?


Hi there.

After testing Particle.connected() and

bool success;
success = Particle.publish("motion-detected");
if (!success) {
  // get here if event publish did not work

in order to detect a suden internet interruption while sending data, I found that the new WITH ACK flag
is able to instantly discover the problem, which is great.

However, I seems that it doesn’t have a timeout and waits forever for the confirmation of success.
There’s a way to timeout it in order to regain the control of my code?

Thanks in advance for the time and help.


Jo @gavpret, it should timeout in 30 seconds. Under what circumstance are you finding that the publish will not send?


Hi @BDub and thank you for your reply.
I need a way to confirm that the publish was done,
since my device will be used in a place that could suffer internet outrages.

What I’m doing to roughly test the system, is simply turn off the WiFi router while the Photon is sending a series of Particle.publish() instructions. I also added a couple of instructions to turn on the blue LED before the Particle.publish() command and turn it off after. In the moment that I turned off the router the code stopped (wich is great since interrogating the success of Particle.publish() with the router turned off, only resulted in false after 5 more instances of the command, and Particle.connected() never detected the issue), however the blue LED never turned off which indicates that the command never did timeout.

Thank you for your help.


If you are running in default SYSTEM_MODE(AUTOMATIC) without SYSTEM_THREAD(ENABLED) you code will block entirely when the connection is lost.
It’s not only the Particle.publish() that blocks.


Hi @ScruffR.
Thank you for your reply.

I’m running in semi-automatic mode and with system thread enabled. I also did the same test without the flag and the code continued to execute as expected.


Hmm, I just ran a test and it appears with using a iPhone Wi-Fi hotspot, the timeout is 21 seconds, which makes sense because it’s trying to connect to Wi-Fi 3 times at 7 second timeouts for each in the background in WICED.


const uint32_t PUBLISH_INVERVAL = 2000;
int count = 1;

void setup() {

void loop() {
    static uint32_t lastPublish;

    if (millis() - lastPublish > PUBLISH_INVERVAL)
        lastPublish = millis();
        bool success = false;
        success = Particle.publish("publish-with-ack", String(count), PRIVATE, WITH_ACK);
        if (!success) {
            Serial.printlnf("%7d(s): publish failed: %d", millis()/1000, count);
        else {
            Serial.printlnf("%7d(s): publish passed: %d", millis()/1000, count);
     24(s): publish passed: 12
     26(s): publish passed: 13
     28(s): publish passed: 14
     30(s): publish passed: 15 // switched off the hotspot at 30s
     52(s): publish failed: 16
     74(s): publish failed: 17
     95(s): publish failed: 18
    116(s): publish failed: 19
    140(s): publish failed: 20 // switched hotspot back on
    141(s): publish passed: 21
    142(s): publish passed: 22
    144(s): publish passed: 23
    146(s): publish passed: 24

@gavpret can you give this a try on firmware 0.6.1?


Hi @BDub. Thank you for your message.

Here are my results (FW 0.6.1):

  7(s): publish passed: 1
  7(s): publish passed: 2
  9(s): publish passed: 3
 11(s): publish passed: 4
 13(s): publish passed: 5
 15(s): publish passed: 6
 17(s): publish passed: 7
 19(s): publish passed: 8
 21(s): publish passed: 9
 23(s): publish passed: 10
 25(s): publish passed: 11 ////// WIFI ROUTER OFF and 3 MINUTE WAIT...
230(s): publish failed: 12  ////// WIFI ROUTER ON
231(s): publish failed: 13
238(s): publish passed: 14
238(s): publish passed: 15
240(s): publish passed: 16
242(s): publish passed: 17
244(s): publish passed: 18
246(s): publish passed: 19
248(s): publish passed: 20
250(s): publish passed: 21
252(s): publish passed: 22


I wonder what’s different between your router powering off, and my hotspot powering off. When I shut mine down the Photon’s RGB LED is blinking Green. What does yours do? Are you physically turning off the power to the router, or disabling the internet via a control panel on your router?


Mine quickly blinks green too. I´m physically turning off my router. I will try with a hotspot and report in a few minutes. Thank you for you help!


@BDub certainly the use of the hotspot changes the behavior.

Here are my results using an iPhone hotspot:

  6(s): publish passed: 3
  8(s): publish passed: 4
 10(s): publish passed: 5
 12(s): publish passed: 6
 14(s): publish passed: 7
 16(s): publish passed: 8
 18(s): publish passed: 9
 20(s): publish passed: 10
 22(s): publish passed: 11
 24(s): publish passed: 12  ///// HOTSPOT TURNED OFF
 26(s): publish failed: 13
 49(s): publish failed: 14
 49(s): publish failed: 15
 51(s): publish failed: 16
 63(s): publish passed: 17  ///// TURNED ON
 63(s): publish passed: 18
 65(s): publish passed: 19
 67(s): publish passed: 20
 69(s): publish passed: 21
 71(s): publish passed: 22
 73(s): publish passed: 23
 75(s): publish passed: 24
 77(s): publish passed: 25
 79(s): publish passed: 26
 81(s): publish passed: 27
 83(s): publish passed: 28
 85(s): publish passed: 29
 87(s): publish passed: 30


Another test, this time I kept my router ON but disconnected the network cable from the broadband router.

The Photon started to cycle between, blinking green, fast blinking green, blinking white, 2 red blinks, and starting again.

 34(s): publish passed: 12
 36(s): publish passed: 13
 38(s): publish passed: 14
 40(s): publish passed: 15
 42(s): publish passed: 16
 44(s): publish passed: 17
 46(s): publish passed: 18
 68(s): publish failed: 19 ///// NETWORK CABLE DISCONNECTED
246(s): publish failed: 20 ///// CABLE CONNECTED
247(s): publish passed: 21
248(s): publish passed: 22
250(s): publish passed: 23
252(s): publish passed: 24
254(s): publish passed: 25
256(s): publish passed: 26
258(s): publish passed: 27


Hi @BDub. I hope that you are doing great.
Any thoughts about this issue?

Thank you!


@gavpret I can confirm there is an unexpected issue here with the WITH_ACK flag. Please watch this issue for the resolution, expected to be fixed in 0.7.0


Thank you, @BDub.


Can you also confirm that this is the case on the Electron. It looks like there is no timeout on the with_ack flag at all.

My entire application was hanging, I had another high priority thread running which still continues to run, but the main loop hangs altogether.

I have reverted to no_ack and have implemented my own handler at each end. It’s not as nice but at least it doesn’t block!