# Core sometimes fails to connect to Cloud on startup

**URL:** <https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229>\
**Category:** Cloud\
**Created:** [January 20, 2014, 4:09pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229 "2014-01-20T16:09:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![aboudou](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aboudou/32/26266_2.png) [@aboudou](https://community.particle.io/u/aboudou)\
**Post date:** [January 20, 2014, 4:09pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/1 "2014-01-20T16:09:32Z")

</div>

Hi all,

I’ve received today my battery shield, and wanted to test battery life with a simple script :

1. connect to a server with TCP client
2. ping it (access to a dedicated url, the keeps a log of pings)
3. switch to deep sleep mode for one minute
4. goto step 1

RGB led sequences is:

1. White flashing (C3300 init process ?)
2. Green flashing (WIFI authentication)
3. Cyan flashing (connecting to Spark Cloud)
4. Cyan breathing (script execution)
5. RGB led off (sleep mode)

The scripts seems to work well, but sometimes the core is stuck into “Connecting to the Spark Cloud” until I manually reset it.

I don’t know if this issue cames from my Spark Core, or if sometimes the Spark Cloud may sometimes fails connexion (overloaded or similar issue).

Thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![zach](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/zach/32/20714_2.png) [@zach](https://community.particle.io/u/zach)\
**Post date:** [January 20, 2014, 6:43pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/2 "2014-01-20T18:43:06Z")

</div>

@aboudou where are you located and what is your internet bandwidth? I am guessing this is due to latency to the Cloud; we have some fixes in the works that should improve the robustness of this connection

---

<div class="post-metadata">

**Author:** ![aboudou](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aboudou/32/26266_2.png) [@aboudou](https://community.particle.io/u/aboudou)\
**Post date:** [January 20, 2014, 6:50pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/3 "2014-01-20T18:50:38Z")

</div>

@zach i’m located in France, behind a 7000/1024 kb DSL connection.

---

<div class="post-metadata">

**Author:** ![zach](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/zach/32/20714_2.png) [@zach](https://community.particle.io/u/zach)\
**Post date:** [January 20, 2014, 6:59pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/4 "2014-01-20T18:59:18Z")

</div>

Thanks @aboudou - hopefully this issue will be resolved through improvements we make over the next couple of weeks; if it isn’t resolved in three weeks, will you let us know?

---

<div class="post-metadata">

**Author:** ![aboudou](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aboudou/32/26266_2.png) [@aboudou](https://community.particle.io/u/aboudou)\
**Post date:** [January 20, 2014, 7:06pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/5 "2014-01-20T19:06:42Z")

</div>

Thanks for your answer. I’ll tell you if this issue is resolved or not in three weeks 😃

---

<div class="post-metadata">

**Author:** ![aboudou](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aboudou/32/26266_2.png) [@aboudou](https://community.particle.io/u/aboudou)\
**Post date:** [January 27, 2014, 8:45pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/6 "2014-01-27T20:45:12Z")

</div>

Hi,

I don’t know if Sprint 4 should have fixed this bug, but it seems it’s not the case. I still suffer Spark Cloud connection issues after deep sleep. You can see it here : [http://scbattest.herokuapp.com/](http://scbattest.herokuapp.com/) (first connection at 07:51 p.m GMT; last successful connection 20 minutes later).

I’ve made a factory reset to be sure to get last firmware version, but no changes.

---

<div class="post-metadata">

**Author:** ![zach](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/zach/32/20714_2.png) [@zach](https://community.particle.io/u/zach)\
**Post date:** [January 27, 2014, 11:30pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/7 "2014-01-27T23:30:45Z")

</div>

Can you share any of your code so that we can see what might be going on?

---

<div class="post-metadata">

**Author:** ![aboudou](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aboudou/32/26266_2.png) [@aboudou](https://community.particle.io/u/aboudou)\
**Post date:** [January 28, 2014, 6:03am UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/8 "2014-01-28T06:03:19Z")

</div>

Of course 😄

```
TCPClient client;

void setup() {
}

void loop() {

    if (client.connect("scbattest.herokuapp.com", 80)) {
        client.println("GET /xxxx HTTP/1.1");
        client.println("Host: scbattest.herokuapp.com");
        client.println("User-Agent: Spark Core");
        client.println();
        
        while(!client.available());

        client.flush();
        
        client.stop();
    }

    Spark.sleep(SLEEP_MODE_DEEP,60);
}

```

---

<div class="post-metadata">

**Author:** ![zach](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/zach/32/20714_2.png) [@zach](https://community.particle.io/u/zach)\
**Post date:** [January 28, 2014, 7:43pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/9 "2014-01-28T19:43:04Z")

</div>

Hi @aboudou - I think the issues you’re seeing may relate to problems in the TCP library rather than in the Spark Cloud connectivity. There are a few other threads relating to TCP issues that we’re working through, but there were no fixes applied here during Sprint 4.

---

<div class="post-metadata">

**Author:** ![aboudou](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aboudou/32/26266_2.png) [@aboudou](https://community.particle.io/u/aboudou)\
**Post date:** [January 28, 2014, 7:47pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/10 "2014-01-28T19:47:40Z")

</div>

Thanks for you answer. I’ll just have to wait for TCP library fixes 😄

---

<div class="post-metadata">

**Author:** ![aboudou](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aboudou/32/26266_2.png) [@aboudou](https://community.particle.io/u/aboudou)\
**Post date:** [January 29, 2014, 7:12am UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/11 "2014-01-29T07:12:37Z")

</div>

Hi @zach. I can confirm it may be related to TCP library. I use the following code all night without any issue:

```
void setup() {
}

void loop() {

    delay(2000);

    Spark.sleep(SLEEP_MODE_DEEP,60);
}  
```

---

<div class="post-metadata">

**Author:** ![aboudou](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/aboudou/32/26266_2.png) [@aboudou](https://community.particle.io/u/aboudou)\
**Post date:** [March 4, 2014, 8:36pm UTC](https://community.particle.io/t/core-sometimes-fails-to-connect-to-cloud-on-startup/2229/12 "2014-03-04T20:36:26Z")

</div>

The last firmware release (the one from [https://community.spark.io/t/latest-firmware-released-to-spark-build/3127/22](https://community.spark.io/t/latest-firmware-released-to-spark-build/3127/22)) seems to have fixed TCP client stability.

Thanks 🙂
