# Cloud Function Timing Out

**URL:** <https://community.particle.io/t/cloud-function-timing-out/8258>\
**Category:** Troubleshooting\
**Created:** [November 19, 2014, 6:58am UTC](https://community.particle.io/t/cloud-function-timing-out/8258 "2014-11-19T06:58:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mvd7793](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mvd7793/32/3641_2.png) [@mvd7793](https://community.particle.io/u/mvd7793)\
**Post date:** [November 19, 2014, 6:58am UTC](https://community.particle.io/t/cloud-function-timing-out/8258/1 "2014-11-19T06:58:54Z")

</div>

Hello! I’m trying to call a basic cloud function I added to my INO file. For simplicity’s sake, I’ve commented everything else out in the code except the call to `Spark.function()` and the function itself, which simply returns 1. Following the exact curl in the examples, I continuously get:

`{ "ok": false, "error": "Timed out." }`

I’m down to the most basic example I can get. Any ideas on where I should start debugging? I’m running `curl https://api.spark.io/v1/devices/<my device ID>/<my function name> -d access_token=<my access token> -d "args=1"`.

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [November 19, 2014, 7:06am UTC](https://community.particle.io/t/cloud-function-timing-out/8258/2 "2014-11-19T07:06:36Z")

</div>

Where did you add the `Spark.function()` to `setup()`?

---

<div class="post-metadata">

**Author:** ![harrisonhjones](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/harrisonhjones/32/4132_2.png) [@harrisonhjones](https://community.particle.io/u/harrisonhjones)\
**Post date:** [November 19, 2014, 3:10pm UTC](https://community.particle.io/t/cloud-function-timing-out/8258/3 "2014-11-19T15:10:44Z")

</div>

Posting the code you are flashing to your core would be of great help. Would you minding doing so when you reply?

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [November 19, 2014, 3:14pm UTC](https://community.particle.io/t/cloud-function-timing-out/8258/4 "2014-11-19T15:14:00Z")

</div>

One other thing that comes up a lot is that Spark.function names are limited to 12-characters and get truncated so that when you use curl to call the longer name you think you have, you see this error. You can use a GET request to find the actual name or just check your code.

---

<div class="post-metadata">

**Author:** ![mvd7793](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mvd7793/32/3641_2.png) [@mvd7793](https://community.particle.io/u/mvd7793)\
**Post date:** [November 19, 2014, 4:33pm UTC](https://community.particle.io/t/cloud-function-timing-out/8258/5 "2014-11-19T16:33:48Z")

</div>

Ah - it turns out `setBrightness` is 13 characters, which is what did it.

A few recommendations:

- You mention the 12 character limit on the `Core Code (Firmware)` page, but not on `Cloud Code (API)`, which is where people will be when they’re actually trying to call a function. It would be great to get a mention of the limit added to the `CONTROLLING A CORE` section.
- From a technical perspective, a 10 second timeout when a method name is not found is a relatively bad developer experience. You’re much more familiar with your systems than I am, but having the Core return a “Not Found” error (or maintaining a server side index of functions that are enabled, since the Core in question must be on the Internet to receive a function request in the first place, and catching it at the API layer) would be extremely helpful.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [November 19, 2014, 4:37pm UTC](https://community.particle.io/t/cloud-function-timing-out/8258/6 "2014-11-19T16:37:44Z")

</div>

Glad it is working for you now.

Your other remarks are best directed to Spark staff – perhaps @Dave can capture this request for the cloud to improve.

---

<div class="post-metadata">

**Author:** ![harrisonhjones](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/harrisonhjones/32/4132_2.png) [@harrisonhjones](https://community.particle.io/u/harrisonhjones)\
**Post date:** [November 19, 2014, 4:46pm UTC](https://community.particle.io/t/cloud-function-timing-out/8258/7 "2014-11-19T16:46:09Z")

</div>

Hey @mvd7793, you can always do a GET to [https://api.spark.io/v1/devices/DEVICE\_ID/?access\_token=ACCESS\_TOKEN](https://api.spark.io/v1/devices/DEVICE_ID/?access_token=ACCESS_TOKEN) to get a list of active function on a core.

I do agree however, a 10 second timeout is a little long. It would also be nice if the WEB IDE checked spark.function calls for names longer than 12 characters.

@mvd7793, I have added a pull request for the spark docs ([https://github.com/spark/docs/pull/250](https://github.com/spark/docs/pull/250)). Would that additional have helped you?
