Https Server API's GET/POST on GCP

Hi,

I’ve been using the HttpClient library for posting data out endpoints (http) server. New server is using Https on GCP, what HttpsClient library is currently supported for Boron? Not seeing anything current/supported when searching using Particle CLI/library search.

There is no built-in support for https on the Particle platform. The recommended method is to use webhooks.

If you must use direct https, the best TLS/SSL library is hirotakaster's library, but it's only TCP. You still need to implement HTTP on top of it. Also note that https uses a lot of data, it could use as much as a 5K per connection just for negotiation, so keep that in mind.

1 Like

Hi,
Another option could be to use the Particle-Google Cloud integration.
Best

1 Like

Incidentally, I really like the Google Cloud Platform integration. I use it at my home. It converts Particle events (Particle.publish) into GCP PubSub events.

The reason this is useful is that GCP PubSub events are queued until delivered, and have reliable delivery. And you can subscribe from behind a firewall/NAT with no network reconfiguration. It’s also secure without requiring a SSL certificate for your server.

The other advantage is that GCP PubSub has exactly once delivery. You can subscribe from multiple servers and each event will be delivered to exactly one subscriber. This is great for load-balancing and for redundancy.

While Particle SSE also allows subscription from behind firewall/NAT, GCP subscription will queue the events if the events are not received by the subscriber. Particle SSE discards the events. And if you have multiple Particle SSE listeners, the events are delivered to all of them, which requires that you handle deduplication yourself.

3 Likes

Yes, TlsTcpClient is just a TLS connection only, so have to implement the HTTP protocol yourself with lib.
This lib is an option when the device really wants to use TLS on its own.
In addition to the problem of TLS is verrry fat, there is also the problem of certificate handling(certificate’s expire…etc) if implements TLS/HTTPS on yourself.

As rick wrote, I would also recommend webhooks.

If I were to add something, I think the device don’t have to use HTTPS protocol on it’s self.
Because, TLS and certificates files are hard to use&handling, so if there is a lighter way, it is better for the device to use that.

3 Likes

How/Where would I insert the server cert in this code?


#include "httpsclient-particle/httpsclient-particle.h"

const char* host = "your-https-endpoint.com";
const char* path = "/your-post-path";
const char* contentType = "application/json";
const char* body = "{\"key\": \"value\"}";

void setup() {
  Serial.begin(9600);
}

void loop() {
  HTTPSClient client;

  if (client.connect(host)) {
    Serial.println("Connected");

    client.post(path, contentType, body);

    Serial.print("Response code: ");
    Serial.println(client.responseStatusCode());

    Serial.print("Response body: ");
    Serial.println(client.responseBody());

    client.stop();
  } else {
    Serial.println("Connection failed");
  }

  delay(5000);
}

@hirotakaster @rickkas7

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.