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".
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.
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.
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.