I am creating a logic that preprocesses incoming data from mqtt broker A and then publishes it to broker B.
const client: MqttClientType = {
publish: null,
subscribe: null,
};
const mqttClient = mqtt.connect(mqttConnectOptions);
I created a new client by changing the Client ID and Broker ID of the Client Option.
However, I don't know if it's because only one mqtt library is used, but when the pub client is called, the sub's client information remains intact and published as a sub client.
This is part of the log.
{"level":30,"time":1673401661860,"pid":78,"hostname":"90489ad744e6","name":"maq-server","options":{"clientId":"maq-broker","host":"maq-broker","port":1883,"protocol":"mqtt","clean":true,"defaultProtocol":"mqtt","keepalive":60,"reschedulePings":true,"protocolId":"MQTT","protocolVersion":4,"reconnectPeriod":1000,"connectTimeout":30000,"resubscribe":true,"hostname":"main-broker"},"messageIdProvider":{"nextId":63626},"outgoingStore":{"options":{"clean":true},"_inflights":{}},"incomingStore":{"options":{"clean":true},"_inflights":{}},"queueQoSZero":true,"_resubscribeTopics":{}
I want to be published as maq-broker, but main-broker information remains inside.
I've looked elsewhere, but I haven't found a case of using the broker client twice.
Each mqtt client is created as an intermediary and requests are made, but the client created first is called.