{"id":19194840,"url":"https://github.com/golain-io/mqtt-bridge","last_synced_at":"2025-04-10T04:00:30.413Z","repository":{"id":261872109,"uuid":"885593173","full_name":"golain-io/mqtt-bridge","owner":"golain-io","description":"Bridge gRPC and other protocols over MQTT connections.","archived":false,"fork":false,"pushed_at":"2025-02-17T11:15:27.000Z","size":156,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T05:13:32.332Z","etag":null,"topics":["go","golang","grpc","iot","mqtt","mqtt-bridge"],"latest_commit_sha":null,"homepage":"https://golain.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/golain-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T22:34:14.000Z","updated_at":"2025-02-17T11:14:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"d8896cc5-01ae-4bb1-9058-900ca3ead72e","html_url":"https://github.com/golain-io/mqtt-bridge","commit_stats":null,"previous_names":["golain-io/mqtt-bridge"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golain-io%2Fmqtt-bridge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golain-io%2Fmqtt-bridge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golain-io%2Fmqtt-bridge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/golain-io%2Fmqtt-bridge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/golain-io","download_url":"https://codeload.github.com/golain-io/mqtt-bridge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154995,"owners_count":21056542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","grpc","iot","mqtt","mqtt-bridge"],"created_at":"2024-11-09T12:06:04.152Z","updated_at":"2025-04-10T04:00:30.250Z","avatar_url":"https://github.com/golain-io.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MQTT-Bridge\n\nMQTT-Bridge is a library that allows you to bridge protocols over MQTT, with a focus on gRPC. It provides two implementations:\n\n- Network Bridge: A low-level implementation that allows existing gRPC clients and servers to communicate over MQTT without modification. The network bridge provides a `net.Listener` and `net.Conn` interface.\n- gRPC Bridge: A higher-level implementation that works directly with MQTT messages while maintaining gRPC-style APIs. The gRPC bridge provides a `grpc.ServiceRegistrar` and `grpc.ServiceInfoProvider` interface.\n\nIn theory, the network bridge should work with anything that uses the `net.Listener` and `net.Conn` interfaces, such as HTTP servers and other networking libraries.\n\n\n# Example Overview\n\nThis example demonstrates how to use mqtt-bridge to enable gRPC-style communication over MQTT. The project includes two different implementations showing how to bridge gRPC and MQTT communications.\n\n## Overview\n\nThe example implements a simple Echo service with three types of RPCs:\n- Unary calls (simple request-response)\n- Server streaming (server sends multiple responses)\n- Bidirectional streaming (both client and server can send multiple messages)\n\n## Prerequisites\n\n- Go 1.19 or later\n- An MQTT broker (e.g., Mosquitto) running on localhost:1883\n- Protocol buffer compiler (protoc)\n\n## Service Definition\n\nThe Echo service is defined in the proto file:\n```proto:example/echo.proto\nstartLine: 6\nendLine: 15\n```\n\n## Implementation Options\n\n### 1. Network Bridge Implementation\n\nThe network bridge provides a low-level network implementation that allows existing gRPC clients and servers to communicate over MQTT without modification.\n\n#### Server Setup\n```go:example/net_bridge/server/main.go\nstartLine: 34\nendLine: 45\n```\n\n#### Client Setup\n```go:example/net_bridge/client/main.go\nstartLine: 37\nendLine: 55\n```\n\nTo run:\n```bash\n# Start the server\ngo run example/net_bridge/server/main.go\n\n# In another terminal, start the client\ngo run example/net_bridge/client/main.go\n```\n\n### 2. gRPC Bridge Implementation\n\nThe gRPC bridge provides a higher-level abstraction that works directly with MQTT messages while maintaining gRPC-style APIs.\n\n#### Server Setup\n```go:example/grpc_bridge/server/main.go\nstartLine: 33\nendLine: 39\n```\n\n#### Client Setup\n```go:example/grpc_bridge/client/main.go\nstartLine: 30\nendLine: 51\n```\n\nTo run:\n```bash\n# Start the server\ngo run example/grpc_bridge/server/main.go\n\n# In another terminal, start the client\ngo run example/grpc_bridge/client/main.go\n```\n\n## Service Implementation\n\nThe Echo service implements three types of RPCs:\n\n1. Unary Call - Simple request-response:\n```go:example/echo_service.go\nstartLine: 23\nendLine: 33\n```\n\n2. Server Streaming - Server sends multiple responses:\n```go:example/echo_service.go\nstartLine: 36\nendLine: 55\n```\n\n3. Bidirectional Streaming - Both sides can send messages:\n```go:example/echo_service.go\nstartLine: 58\nendLine: 82\n```\n\n## Key Features\n\n- Seamless conversion between gRPC and MQTT communication\n- Support for all gRPC communication patterns:\n  - Unary calls\n  - Server streaming\n  - Client streaming\n  - Bidirectional streaming\n- Automatic message framing and protocol handling\n- Integration with existing gRPC tooling\n- Choice between network-level and message-level implementations\n\n## Notes\n\n- The network bridge implementation is ideal when you want to use existing gRPC code over MQTT\n- The gRPC bridge implementation is better when you want to work directly with MQTT messages while maintaining gRPC-style APIs\n- Both implementations support the full range of gRPC features\n- Ensure your MQTT broker is properly configured and accessible before running the examples\n- The gRPC bridge implementation has not been tested for streaming RPCs, only unary has been tested as of now.\n\n## License\n\nMIT License\n\n## Copyright\n\nCopyright 2024 Golain Systems Private Limited.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolain-io%2Fmqtt-bridge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgolain-io%2Fmqtt-bridge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgolain-io%2Fmqtt-bridge/lists"}