Node.js integration

Hi,

We would like to receive uplink & send downlink messages using Node.js, as per documentation v2.3.3 is deprecated and suggested to use v1.3.2. But I’m unable to find v1.3.2 sample code, the samples are related to v2.3.3 and doesn’t work with v1.3.2.

Could someone be so kind to post a v1.3.2 sample.

Thanks

The node.js integration is deprecated in all versions. What have you the idea the older version should be used?

Use the generic MQTT connector in stead.

To use this SDK with the deprecated staging environment

This refers to an obsolete TTN environment, not the current one or the new V3 that may be implemented later this year.

Alright the npm.js repo mentioned to use v1.3.2 and v2.3.3 is not installable at all.

Anyway coming back to the generic mqtt implementation I have managed to establish connection but not able to receive any uplink message.

var client = mqtt.connect((‘mqtt://asia-se.thethings.network:1883’), {
username: appID,
password: accessKey
});

client.on(‘connect’, () => console.log(“connected”));
client.on(‘message’, (message) => console.log(message));
client.on(‘uplink’, (uplink) => console.log(uplink));
client.on(‘error’, (err) => console.log(err));

On the console “connected” is getting printed, but nothing after that. Any idea what am I doing wrong here?

Never mind, it seems subscribe is required. Now its working, Thanks for the help.

var client = mqtt.connect((‘mqtt://asia-se.thethings.network:1883’), {
username: appID,
password: accessKey
});

client.on(‘connect’, () => {
console.log(“connected”);
client.subscribe([’+/devices/+/activations’, ‘+/devices/+/up’]);
});

client.on(‘message’, (topic, message) => {
var payload = JSON.parse(message.toString());
console.log(payload.dev_id, payload.payload_raw);
});

client.on(‘error’, (err) => console.log(err));

1 Like

No. It mentions you need to use 1.3.2 for the old (replaced over two years ago) environment. Please read carefully, in computing the details do matter as computers take things literally :sunglasses:

1 Like