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;
var token = process.env.TDENGINE_CLOUD_TOKEN;
async function createConnect() {
let conn = null;
try {
let conf = new taos.WSConfig(url);
conf.setToken(token);
conn = await taos.sqlConnect(conf);
} catch (err) {
throw err;
} finally {
if (conn) {
await conn.close();
}
}
}
Frequently Asked Questions
-
Using REST connections requires starting taosadapter.
sudo systemctl start taosadapter
-
"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
version | TDengine version | Description |
---|---|---|
3.1.1 | 3.3.2.0 or later | Optimized data transfer performance |
3.1.0 | 3.2.0.0 or later | new version, supports websocket |