node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

Stomp node: error sending payload as XML

Open martin-doyle opened this issue 9 months ago • 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:

  • [X] Node-RED version: 3
  • [X] node.js version: 18
  • [X] npm version: 10.7
  • [X] Platform/OS: Linux, Windows
  • [X] 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();
                }
            });

martin-doyle avatar May 14 '24 09:05 martin-doyle