Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing MQTT using Google cloud pub sub in flutter

Is there any way to establish a connection with Google IoT pub-sub API in flutter?

I tried this library but it doesn't have the configuration which I am looking for.

I have the following data which will be used to establish the connection:

{
  "type": ,
  "project_id": ,
  "private_key_id": ,
  "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
  "client_email": ,
  "client_id": ,
  "auth_uri": ,
  "token_uri": ,
  "auth_provider_x509_cert_url": ,
  "client_x509_cert_url": 
}
like image 633
Dhaval Kansara Avatar asked Dec 05 '19 10:12

Dhaval Kansara


People also ask

Does Google Cloud support MQTT?

Cloud IoT Core supports the MQTT protocol by running a managed broker that listens to the port mqtt.googleapis.com:8883 . Port 8883 is the standard TCP port reserved with IANA for secure MQTT connections.

What is the use of pub/sub in GCP?

Google Cloud Pub/Sub provides messaging between applications. Cloud Pub/Sub is designed to provide reliable, many-to-many, asynchronous messaging between applications. Publisher applications can send messages to a "topic" and other applications can subscribe to that topic to receive the messages.

How does cloud pub/sub deliver messages to endpoints?

Push subscriptionThe Pub/Sub server sends each message as an HTTPS request to the subscriber client at a pre-configured endpoint. This request is shown as a PushRequest in the image. The endpoint acknowledges the message by returning an HTTP success status code.


1 Answers

You can use gcloud package in your flutter app. It provides support for Cloud Datastore, Cloud Storage, and Cloud Pub/Sub. Hope it helps.

P.S. Don't use any third-party libraries to connect with Google services. It may not have full support or may stop working at any point of time. Use libraries that are being provided by Google. Other client libraries for Google PubSub are listed here.

like image 200
Nirav Tukadiya Avatar answered Oct 13 '22 01:10

Nirav Tukadiya