0

我有 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 和后端之间进行路由?

谢谢!

4

0 回答 0