node-red/node-red-nodes

Stomp node: error sending payload as XML

Opened this issue · 0 comments

Which node are you reporting an issue on?

Stomp

What are the steps to reproduce?

  • Format payload as XML
  • Send payload via stomp out node

What happens?

  • Payload as JSON with XML inside

What do you expect to happen?

  • Payload as XML

Please tell us about your environment:

  • Node-RED version: 3
  • node.js version: 18
  • npm version: 10.7
  • Platform/OS: Linux, Windows
  • Browser: Chrome, Edge

When started

commit 0d7f0cb
STOMP refactor in accordance with MQTT (shared connection using confi…

Before

	node.on("input", function(msg) {
            node.client.publish(node.topic || msg.topic, msg.payload, msg.headers);
        });

After

            node.on("input", function(msg, send, done) {
                if (node.topic && msg.payload) {
                    try {
                        msg.payload = JSON.stringify(msg.payload);
                    } catch {
                        msg.payload = `${msg.payload}`;
                    }
                    node.serverConnection.publish(node.topic, msg.payload, msg.headers || {});
                    done();
                }
            });