Hi, I am trying to send an empty MQTT message on a specified topic. This is a common pattern with MQTT to 'query' the status of an MQTT connected device.
I am using the project in a React Native app and can connect, subscribe and send (non-empty) messages fine. I am not sure how to send and empty message though.
The below code works fine and sends the payload 0 on the topic specified in device.command:
const _message = new Message('0');
_message.destinationName = device.command;
this.onMessageSendHandler(_message);
In order to try and send empty messages I tried to create the new message object in the following two ways both of which returned errors:
to test not passing and parameter to the object creation
const _message = new Message();
Error received: TypeError: undefined is not and object (evaluating 'newPayload.toString')
to test an empty string:
const _message = new Message('');
Error received: Error: AMQJS0011E Invalid state not connected.
to test an empty array:
const _message = new Message([]);
Error received: AMQJS0013E Invalid argument for newPayload.
to test an empty JavaScript object as a string:
const _message = new Message('{}');
Error received: Error: AMQJS0011E Invalid state not connected.
to test an empty JavaScript object:
const _message = new Message({});
Error received: AMQJS0013E Invalid argument for newPayload.
So I am not sure how to send and empty message with this client library. Did I miss something obvious or not so obvious?
Hi, I am trying to send an empty MQTT message on a specified topic. This is a common pattern with MQTT to 'query' the status of an MQTT connected device.
I am using the project in a React Native app and can connect, subscribe and send (non-empty) messages fine. I am not sure how to send and empty message though.
The below code works fine and sends the payload
0
on the topic specified indevice.command
:In order to try and send empty messages I tried to create the new message object in the following two ways both of which returned errors:
to test not passing and parameter to the object creation
TypeError: undefined is not and object (evaluating 'newPayload.toString')
to test an empty string:
Error: AMQJS0011E Invalid state not connected.
to test an empty array:
AMQJS0013E Invalid argument for newPayload.
to test an empty JavaScript object as a string:
Error: AMQJS0011E Invalid state not connected.
to test an empty JavaScript object:
AMQJS0013E Invalid argument for newPayload.
So I am not sure how to send and empty message with this client library. Did I miss something obvious or not so obvious?