Electron TCP callFunction

I am having an Issue where the electron takes ~20 to ~30seconds for the first request to call a function on the device. The Following function requests take ~2 seconds. Why is the initial request after a period of time substantially longer ???

Following this i tried to set the Electron to TCP instead of UDP, the firmware upgrade was successful but i can no longer access any functions inside the device through the API (functions : null) . If i change it back to UDP i can access the functions remotely again.

Why is the initial function request so long (does it go to sleep after 30 seconds or something ??)
Why cant i access cloud functions with the electron after changing to TCP

Can you try this with tinker? Turn on/off the D7 LED via a function call.

The electron doesn’t sleep by default. It could be a connection issue related to your cellular network that takes a long time to establish the connection to the device.

Ok so after using the tinker app the first and future responses are ~4 seconds. Its only if i use the spark api that it is considerably slower for the first request (30 seconds) . Why is the spark API so slow ?

EG (takes 30 seconds if left alone for a while)

Where as doing this in the TINKER app takes ~4 Seconds

(Note - both tinker and API request are on the same network)

I have no idea - the tinker app is using the same API.

Ok so some more info .

If i call it from the App, then from the web , then from the app again, the app can take 30 seconds to complete. Its almost like the spark api is caching the last device or request that it has recieved.

Yea i just looked at the source code for the Tinker app and noticed that too. The issue is very reproducable if

  • You request the device from 1 source (eg the app)
  • Leave it for a minute
  • Request it from another source (eg a direct post request)

On a second note, why arnt functions remotely available after switching the electron to use TCP, if i could switch to TCP (where i know this issue doesnt exist on my photons) then it might help solve it