Photon keeps disconnect and reconnect to the cloud

My original codes were similar to that tutorial:

void setup() {
        pinMode(D0, INPUT_PULLUP);
}

void loop() {
    if (digitalRead(D0) == LOW) {
        Particle.publish("telegram-user", "A car just passed.", 60, PRIVATE);
        while (digitalRead(D0) == LOW);
    }
}

Currently the photon + loop detector are still on my table. And it will be used in private street so it won’t hit that rate limit.

I don’t see any code blocking delay() in that original code.