node.js - 如何将相同的消息广播到 Mosca 中的多个接口
问题描述
我有 2 个接口,一个 mqtt 和一个用于 websocket。我注意到如果我有后端,mqtt 不会路由到 websocket。
我创建了 mosca 服务器,如下所示:
server = new mosca.Server(
{
interfaces:
[
{ type: "mqtt", port: 1883 },
{
type: "mqtts",
port: 8443,
credentials: { keyPath: SECURE_KEY, certPath: SECURE_CERT }
},
{ type: "http", port: 4000, bundle: true }
],
onQoS2publish: "noack",
logger: { name: 'MoscaServer', level: 'debug' },
backend: {
type: "mqtt",
json: false,
mqtt: require("mqtt"),
key: filesys.readFileSync(__dirname + "/certs/private.key"),
cert: filesys.readFileSync(__dirname + "/certs/cert.pem"),
ca: filesys.readFileSync(__dirname + "/certs/rootCA.cer"),
clientId: "randomClientId",
port: 8883,
host: "<aws IOT endpoint>.iot.<aws region>.amazonaws.com",
rejectUnauthorized: false,
protocol: "mqtts"
},
}
);
我需要做什么才能在所有 3:mqtt、websocket 和后端之间进行路由?
谢谢!
解决方案
推荐阅读
- raspberry-pi - 发现 Raspbian 上的 Pycharm 没有 JDK
- python - (Python3)多次访问字典更好,还是对项目的值进行引用?
- firebase - Flutter Firebase RealTime Databasee 无法使用 OrderByChild() 正确排序
- python - 使用 ProtoBuf 的相对导入:使用 ProtoBuf 生成 Python 类会给出 ModuleNotFoundError
- r - 基于 $ 提取单词并取消嵌套数据
- php - 如何将 Javascript 小程序嵌入 Wordpress 中的元框
- javascript - 是否可以将 svg g 转换为 html div?
- unity3d - 在代码中更改车轮碰撞器中的参数
- image - 验证集扩充 PyTorch 示例
- javascript - 收集输入数据并在 div 中显示