Receiving data from, nothing coming in?


I while ago I was toying around on, sending some temperature readings over TTN. Everything worked great after some fiddling and I was able to poll for the data with a piece of nodejs script.

Today I tried the same thing, but this time using I'm still able to send messages, and see the data coming in on, but I seem to be unable to poll for the data.

Even when I just use the simplest piece if code, it seems like it never gets triggered:

var ttn = require('ttn');
var appEUI = 'xxx';
var accessKey = 'yyy';
var client = new ttn.Client('', appEUI, accessKey);

client.on('uplink', function (msg) {
  console.log('Received message', msg);

client.on('activation', function (msg) {
  console.log('Device activated:', msg.devEUI);

I can't imagine there's anything wrong with the code, so I'm guessing there is some kind of setting in the console I'm overlooking. Any ideas where I'm going wrong?

(Arjan) #2

Which version of the library are you using? Your code seems to be outdated.

Please add some error reporting:

client.on('error', function(err) {
  console.error('[ERROR]', err.message);

Also, it seems you're missing the region when connecting, and I doubt appId is the same as AppEUI:

var client = new ttn.Client(region, appId, accessKey);

See the example for much more logging, as linked from the README.


Thanks Arjan, seems like I was indeed working with a outdated example. replacing appEUI with the appId and adding the region was all I needed to do to get it back working again.

(Arjan) #4

I'd still add the error logging :slight_smile:


I will :slight_smile:

(Jacklin) #6

Hi Eric & Arjan

I used code below but the result is different from the normal.

var ttn = require('ttn');
var region = '';
var appId = '<redacted>';
var accessKey = '<redacted>';
var client = new ttn.Client(region, appId, accessKey);

client.on('message', function(deviceId, data) {'[INFO] ', 'Message:', deviceId, JSON.stringify(data, null, 2));

The code above won't show any message from my node,
but when I replace the 'message' with 'uplink' as v.1 setting in staging,
it will show some information of port and packet counter, but the fields & metadata will show ''undefined'' .

client.on('uplink', function(deviceId, data) {'[INFO] ', 'Message:', deviceId, JSON.stringify(data, null, 2));

Any setting where I'm wrong?
please kindly advise it. Thank you

(Arjan) #7

@jacklin, I'd guess you're using an old version of the library. Also, be sure to add client.on('error', ...).