[Bug]: Unable to subscribe to MQTT Tagged Data Topic using NodeJs
Closed this issue · 2 comments
anistark commented
Issue description
Code Snippet used:
import { Client, initLogger } from '@iota/client';
const client = new Client({
nodes: ['https://api.testnet.shimmer.network'],
});
export async function subscribe(tag) {
initLogger();
// room hex encoded
let tagHex = '0x' + Buffer.from(room, 'utf8').toString('hex');
let roomTopic = 'blocks/tagged-data/' + tagHex;
const topics = [roomTopic];
console.log('topics:', topics);
const callback = function (error, data) {
console.log(JSON.parse(data));
};
await client.listen(topics, callback);
// Clear listener after 10 seconds
setTimeout(async () => {
await client.clearListeners(['blocks']);
console.log('Listener cleared');
// Exit the process
setTimeout(async () => process.exit(0), 2000);
}, 10000);
}
Version
"@iota/client": "^3.0.0-rc.5",
Expected behaviour
Should subscribe to the MQTT Topic.
Actual behaviour
Getting Error InvalidMqttTopic("blocks/tagged-data/0x74657374")
Can the issue reliably be reproduced?
Yes
Steps to reproduce the issue
Run the code above
Errors
thread '<unnamed>' panicked at 'invalid MQTT topic: InvalidMqttTopic("blocks/tagged-data/0x74657374")', src/message_handler.rs:147:80
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
/.../node_modules/@iota/client/out/lib/MessageHandler.js:17
return (0, bindings_1.listen)(topics, callback, this.messageHandler);
^
Error: internal error in Neon module: invalid MQTT topic: InvalidMqttTopic("blocks/tagged-data/0x74657374")
...
Duplicate declaration
- I have searched the issues tracker this issue and there is none
Code of Conduct
- I agree to follow this project's Code of Conduct
thibault-martinez commented
Hello @anistark, thanks for the report! This should be fixed in 3.0.0-rc.9, let us know if you still have an issue.