[solved] TTN Node.js Application SDK + .NetCore + React

Hello,

I keep getting the following javaScript error with The Things Network Node.js Application SDK

  1. Create dotnet core react application with following command : dotnet new react
  2. Go to directory ClientApp
  3. npm install --save ttn
  4. In the home.js page I paste the code given as example:
    import { data, application } from “ttn”

const appID = “foo”
const accessKey = “ttn-account.eiPq8mEeYRL_PNBZsOpPy-O3ABJXYWulODmQGR5PZzg”

// discover handler and open mqtt connection
data(appID, accessKey)
.then(function (client) {
client.on(“uplink”, function (devID, payload) {
console.log("Received uplink from ", devID)
console.log(payload)
})
})
.catch(function (err) {
console.error(err)
process.exit(1)
})

And getting this error:
index.js:3 Uncaught TypeError: Cannot read property ‘_handle’ of undefined
at index.js:3
at Array.forEach ()
at ./node_modules/grpc/node_modules/set-blocking/index.js.module.exports (index.js:2)
at Object. (log.js:11)
at Object…/node_modules/grpc/node_modules/npmlog/log.js (log.js:309)
at webpack_require (bootstrap 7e7a554883cab0855f1a:678)
at fn (bootstrap 7e7a554883cab0855f1a:88)
at Object. (napi.js:5)
at Object…/node_modules/grpc/node_modules/node-pre-gyp/lib/util/napi.js (napi.js:204)
at webpack_require (bootstrap 7e7a554883cab0855f1a:678)
at fn (bootstrap 7e7a554883cab0855f1a:88)
at Object. (versioning.js:9)
at Object…/node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js (versioning.js:331)
at webpack_require (bootstrap 7e7a554883cab0855f1a:678)
at fn (bootstrap 7e7a554883cab0855f1a:88)
at Object…/node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js (pre-binding.js:3)
at webpack_require (bootstrap 7e7a554883cab0855f1a:678)
at fn (bootstrap 7e7a554883cab0855f1a:88)
at Object. (grpc_extension.js:26)
at Object…/node_modules/grpc/src/grpc_extension.js (grpc_extension.js:62)
at webpack_require (bootstrap 7e7a554883cab0855f1a:678)
at fn (bootstrap 7e7a554883cab0855f1a:88)
at Object…/node_modules/grpc/src/client_interceptors.js (client_interceptors.js:144)
at webpack_require (bootstrap 7e7a554883cab0855f1a:678)
at fn (bootstrap 7e7a554883cab0855f1a:88)
at Object. (client.js:35)
at Object…/node_modules/grpc/src/client.js (client.js:1026)
at webpack_require (bootstrap 7e7a554883cab0855f1a:678)
at fn (bootstrap 7e7a554883cab0855f1a:88)
at Object. (index.js:27)

Configuration:
Node v10.16.2
Dotnet Core 2.2

Any one is having the same problem ?
Thanks a lot
Sebastien

The solution was to build a node.js server and use socket.io to exchange data from this server to the React App. If anyone interested, let me know and I will post here the solution.
Best

2 Likes