I’ve built a simple html website that does four things;
Turn on a spark core red LED
Turn off a spark core red LED
Turn on a spark core blue LED
Turn off a spark core blue LED
On the server side (Apache) I’m calling one of four php scripts (see below) that, using curl, posts to the spark api. These php scripts, when executed server side turn the leds on and off and the response header appears almost instantly.
These scripts are simply called by an HTML “form action” button.
What is driving me crazy is that when the form action button is clicked it’s taking 16 seconds to respond. I’m all over the place on trying to solve this.
It would be useful to test if a direct curl call or (REST call) immediately changes the LED. It should. If so, then you know you’ve got a PHP issue as opposed to a core issue.
As dorth said. If the curl goes through instantly. You could find that where your running your server, is running the php slow. It could be many different things. I will gladly help you write your code for this so you dont need 4 php pages as you only need 1
I am running curl from within a php script. Running the php scripts on the server is nearly instant.
Simply running curl outside of the script produces the same desired results as running within the php script. I get the same desired response time running curl
The server is one of mine running CentOS 5.3 and is in a datacenter where I lease space and it’s running fine. I have several other php, perl and tomcat apps running nicely.
The path I’ve been staggering down for the last two days has taken me everywhere but close to the answer.