# Coolpy7消息服务器简介

Coolpy7 (Coolpy7 MQTT Broker) 是基于 Golang 平台开发的开源物联网 MQTT 消息服务器。Golang是出色的并行计算、低延时、分布式 的语言平台。MQTT 是轻量的(Lightweight)、发布订阅模式(PubSub) 的物联网消息协议。

Coolpy7 项目设计目标是承载移动终端或物联网终端海量 MQTT 连接，并实现在海量物联网设备间快速低延时消息路由:

1. 稳定承载大规模的 MQTT 客户端连接，单服务器节点支持100万到1000万连接。
2. 分布式节点集群，快速低延时的消息路由，单集群支持1000万规模的路由。
3. 消息服务器内扩展，支持定制多种认证方式、高效存储消息到后端数据库。
4. 完整物联网协议支持，MQTT、MQTT-SN、WebSocket 或私有协议支持。

### MQTT 发布订阅模式简述

MQTT 是发布订阅(Publish/Subscribe) 模式的消息协议，与 HTTP 协议请求响应(Request/Response) 模式不同。

MQTT 发布者与订阅者之间通过”主题”(Topic) 进行消息路由，主题(Topic) 格式类似 Unix 文件路径，例如:

```
sensor/1/temperature

chat/room/subject

presence/user/feng

sensor/1/#

sensor/+/temperature

uber/drivers/joe/inbox
```

MQTT 主题(Topic) 支持’+’, ‘#’的通配符，’+’通配一个层级，’#’通配多个层级(必须在末尾)。

MQTT 消息发布者(Publisher) 只能向特定’名称主题’(不支持通配符)发布消息，订阅者(Subscriber)通过订阅’过滤主题’(支持通配符)来匹配消息。

{% hint style="info" %}
&#x20;注解

初接触MQTT协议的用户，通常会向通配符的’过滤主题’发布广播消息，MQTT 协议不支持这种模式，需从订阅侧设计广播主题(Topic)。 例如 Android 推送，向所有广州用户，推送某类本地消息，客户端获得 GIS 位置后，可订阅 ‘news/city/guangzhou’ 主题。
{% endhint %}

### 开源 MQTT 客户端项目

&#x20;GitHub: <https://github.com/Coolpy7>

&#x20;Eclipse Paho: <https://www.eclipse.org/paho/>

&#x20;MQTT.org: <https://github.com/mqtt/mqtt.github.io/wiki/libraries>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coolpy7.gitbook.io/coolpy7book/kai-shi-shi-yong/start.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
