Skip to main content

TDengine Node.JS Client Library

@tdengine/websocket is the official Node.js language client library for TDengine. Node.js developers can develop applications to access TDengine instance data. @tdengine/websocket connects to TDengine instances via the WebSocket API.

The source code for the Node.js client library is located on GitHub.

Installation steps

Pre-installation

Install the Node.js development environment

Install via npm

npm install @tdengine/websocket

Establishing a connection

const taos = require('@tdengine/websocket');

var url = process.env.TDENGINE_CLOUD_URL;
async function createConnect() {
let conn = null;
try {
let conf = new taos.WSConfig(url);
conn = await taos.sqlConnect(conf);
} catch (err) {
throw err;
} finally {
if (conn) {
await conn.close();
}
}
}

createConnect();

view source code

Frequently Asked Questions

  1. Using REST connections requires starting taosadapter.

    sudo systemctl start taosadapter
  2. "Unable to establish connection", "Unable to resolve FQDN"

    Usually, the root cause is an incorrect FQDN configuration. You can refer to this section in the FAQ to troubleshoot.

Important update records

versionTDengine versionDescription
3.1.13.3.2.0 or laterOptimized data transfer performance
3.1.03.2.0.0 or laternew version, supports websocket