Connecting to an HTTPS server - often

I’m trying to make a physical button to start and stop my Toggl timer. I’ve tried a few ways of getting it to work, but I keep running into roadblocks.
Toggl provides an API that I could use for that, but it’s HTTPS access only. The ported HTTPS-PARTICLE library is still in beta, and in this application, crashes my Photon.
I could use Particle’s webhooks to talk to the API, but I want the button to be responsive and user webhooks are limited to 10 calls a minute. I was aiming for about one refresh a second (which is the limit of the Toggl API).
I could use a third party interface, Zapier, which has Toggl integration, but it doesn’t provide full access to the elements of the API that I want.
I’ve had a look into the forums and the consensus is generally that the Photon hardware it’s up to a full SSL implementation. I did see an interesting article about wolfSSL, a lightweight SSL client that’s being used to enable HTTPS support in Intel Galileo boards, but porting that to Particle seems like a complex option.
So! Any ideas?

Are you doing something with the button besides taking user input in the form of a button press? The user is unlikely to be pressing the button more than 10 times per second.

Webhooks are limited to 10 calls per minute per device.
The button is taking user input to toggle the timer on or off, so that limit is fine for that function.
I also want the Photon to monitor the timer status in Toggle, and indicate with an LED when the timer is running, since the user can trigger a timer from the website, apps, extensions etc. This is where 10 calls per minute is a bit lax - it might be up to 6 seconds between an event occurring and the visual feedback on the button.

Got it. I wonder if there’s a way for the server to send an event on state change, instead of polling for it. Do you think the Toggl app is polling all the time for a state change? I didn’t see anything in their API, but found this recommendation to use websockets when searching for “Toggl API Push Notification”

That’s interesting! A websocket connection would solve a lot of my issues, and there is an Arduino library. But I notice the example code uses > 'wss://', which I assume is a secured socket… putting me back in the position of needing to implement an SSL library.
Thanks for the recommendation though, I was looking at moving this project over to an ESP8266 and a websocket connection will be much more suitable for the project than constant polling.

I haven’t done anything with the ESP8266 yet, do they support HTTPS? Is there anywhere I could follow your project if you end up switching and drop off the forums here? I use Toggl all the time and would like to have some hardware connected to it someday.

Yeah, the ESP8266 supports SSL in the default SDK and several third party SDKs (CoreMCU in particular). I’m not writing up the project publicly at the moment but I’ll pop a link up on here if it comes to fruition.

1 Like