Skip to content

Commit 09fbfbc

Browse files
authored
fix mqtt topic append with / prefix (#37)
Signed-off-by: Jeeva Kandasamy <jkandasa@gmail.com>
1 parent 39d080c commit 09fbfbc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • plugin/gateway/protocol/protocol_mqtt

plugin/gateway/protocol/protocol_mqtt/client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ func (ep *Endpoint) Write(rawMsg *msgTY.RawMessage) error {
162162
time.Sleep(ep.txPreDelay) // transmit pre delay
163163

164164
for _, t := range topics {
165-
_topic := fmt.Sprintf("%s/%s", ep.Config.Publish, t)
165+
_topic := t
166+
if ep.Config.Publish != "" {
167+
_topic = fmt.Sprintf("%s/%s", ep.Config.Publish, t)
168+
}
166169
rawMsgCloned := rawMsg.Clone()
167170
rawMsgCloned.Others.Set(gwPtl.KeyMqttTopic, _topic, nil)
168171
rawMsgCloned.Timestamp = time.Now()

0 commit comments

Comments
 (0)