We've created and published a simple function that turns sets a pin to HIGH or LOW. We call this function from our PHP web page with cURL. Does anyone know why there an be a lag (sometime up to 10-15 seconds) before the request is received by the Boron board?
The lag is determined by how long after sending the request before a LED on the pin goes on or off. What's interesting is that the lag is always on the request, and not on the response. Immediately after changing the PIN value, we pickup the response back in the cURL call.
We are using OS 4.0.1 on a Boron cellular board. Our project is in the sandbox environment.
Which Boron model? In any case, the first request from the mobile network side to the device after being idle for a period of time may take longer. This is caused by the mobile network.
It's particularly noticeable on the Boron 2G/3G BRN310 and Boron LTE BRN402 due to the SIM provider. There's really no workaround on these models, other than periodically sending data, which would use an enormous amount of data operations and/or cellular data.
I tried from the Particle Console and it never seems to delay. I've created a function that does nothing but receive a string and set a variable with the current timestamp. I can pass it the time from my webserver making the call, and the log the time the board receives it. Then I track the time that I get the response. The delay seems to always be on the way out (e.g. on the call to the particle function, and never on the response).
Does anyone know if this is a sandbox issue? namely, is my request getting queued up somewhere on the way in, but then comes back quick because there is no queue on the way back?
With my code, I've noticed it does take sometimes up to 6-7 seconds from the time the cURL command is issues to the Particle URL before the board registers it in the function.
There is little delay from the time the cloud API receives the function request to the time the UDP CoAP packet is sent. There isn't a huge queue somewhere because the load is distributed across a large number of servers and there are millions of those requests going out constantly.
Also the console doesn't do anything magic to access your devices. It uses the same public API, and in fact when you make a function call request from the console it does it from your browser using the cloud API.
Ok, so maybe just related to the cellular network as you suggested. I think its ok if the first takes time, and we will track to see if we get delays in the middle of making several calls, or if it just occurs after some inactivity.