Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex IoT Core
    • Authentication
    • Resource relationships
    • MQTT server connection parameters
    • Sending messages to an MQTT server via gRPC
    • Backups
    • Quotas and limits
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Data structure
  • Data structure for sending messages on behalf of a device
  • Data structure for sending messages on behalf of a registry
  • Data structure for sending messages to broker clients
  • Use case
  1. Concepts
  2. Sending messages to an MQTT server via gRPC

Sending messages to an MQTT server via gRPC

Written by
Yandex Cloud
Updated at April 18, 2025
  • Data structure
    • Data structure for sending messages on behalf of a device
    • Data structure for sending messages on behalf of a registry
    • Data structure for sending messages to broker clients
  • Use case

You can send messages to an MQTT server on behalf of a device or registry using gRPC. To serialize data, use Protobuf.

You can similarly send messages to broker clients.

Data structureData structure

To send messages to the MQTT server from your software, specify the serializable data structure.

Data structure for sending messages on behalf of a deviceData structure for sending messages on behalf of a device

syntax = "proto3";

package yandex.cloud.iot.devices.v1;

import "google/api/annotations.proto";
import "yandex/cloud/validation.proto";

option go_package = "devices";
option java_package = "yandex.cloud.api.iot.devices.v1";

// A set of methods to work with IoT Core messages on behalf of device
service DeviceDataService {
  // Publishes message on behalf of specified device
  rpc Publish (PublishDeviceDataRequest) returns (PublishDeviceDataResponse) {
    option (google.api.http) = { post: "/iot-devices/v1/devices/{device_id}/publish" body: "*" };
  }
}

message PublishDeviceDataRequest {
  // ID of device publishing message
  string device_id = 1 [(required) = true, (length) = "<=50"];

  // Topic where message should be published
  string topic = 2 [(required) = true, (length) = "<=1024"];

  // Content of the message
  bytes data = 3 [(length) = "<=262144"];
}

Data structure for sending messages on behalf of a registryData structure for sending messages on behalf of a registry

syntax = "proto3";

package yandex.cloud.iot.devices.v1;

import "google/api/annotations.proto";
import "yandex/cloud/validation.proto";

option go_package = "devices";
option java_package = "yandex.cloud.api.iot.devices.v1";

// A set of methods to work with IoT Core messages on behalf of registry
service RegistryDataService {
  // Publishes message on behalf of specified registry
  rpc Publish (PublishRegistryDataRequest) returns (PublishRegistryDataResponse) {
    option (google.api.http) = { post: "/iot-devices/v1/registries/{registry_id}/publish" body: "*" };
  }
}
message PublishRegistryDataRequest {
  // ID of registry publishing message
  string registry_id = 1 [(required) = true, (length) = "<=50"];

  // Topic where message should be published
  string topic = 2 [(required) = true, (length) = "<=1024"];

  // Content of the message
  bytes data = 3 [(length) = "<=262144"];
}

message PublishRegistryDataResponse {
}

Data structure for sending messages to broker clientsData structure for sending messages to broker clients

syntax = "proto3";

package yandex.cloud.iot.broker.v1;

import "google/api/annotations.proto";
import "yandex/cloud/validation.proto";

option go_package = "devices";
option java_package = "yandex.cloud.api.iot.broker.v1";

// A set of methods to work with IoT Core broker messages
service BrokerDataService {
  // Publishes message to broker clients
  rpc Publish (PublishBrokerDataRequest) returns (PublishBrokerDataResponse) {
    option (google.api.http) = { post: "/iot-broker/v1/brokers/{broker_id}/publish" body: "*" };
  }
}
message PublishBrokerDataRequest {
  // ID of broker to publish message
  string broker_id = 1 [(required) = true, (length) = "<=50"];

  // Topic where message should be published
  string topic = 2 [(required) = true, (length) = "<=1024"];

  // Content of the message
  bytes data = 3 [(length) = "<=262144"];
}

message PublishBrokerDataResponse {
}

Use caseUse case

You can find a use case where an MQTT server is contacted via gRPC for JavaScript in the code of the function that emulates sending messages from multiple devices.

Was the article helpful?

Previous
MQTT server connection parameters
Next
Overview
Yandex project
© 2025 Yandex.Cloud LLC