English | 中文
Node-RED nodes for Apache IoTDB and TimechoDB: one SQL interface for the Tree and Table models, plus native Topic subscription with manual ACK.
iotdb-serveris a shared configuration node holding the address, model, database, Node-RED credentials, timeouts and queue limits; Tree and Table each use their own configuration node, and a shared connection cannot change the model or database of other operators.iotdb-operatorruns fixed SQL or the SQL carried inmsg.topicfor queries, writes and management;msg.iotdbreports operation, model, columns, rowCount and timestamp precision, INT64 values stay decimal strings, and a response is bounded at 10,000 rows / 8 MiB instead of being truncated silently.iotdb-consumerpulls from an existing native Topic with a stable groupId and consumerId and emits an opaqueackToken; send the token back to the same node to acknowledge, or usepause/resume. A lost connection makes the consumer reportRECOVERY_REQUIREDand stop pulling, and a persisted marker keeps the same Topic/group from resuming on its own - the marker stores neither messages nor offsets.- Queries run through a pinned
@iotdb/client@2.0.11adaptation layer inside a restricted worker, so Tree timestamps and logical column order survive; a timeout terminates that connection and writes are never retried automatically.
| Server | Data model | SQL | Native subscription | Node.js / Node-RED |
|---|---|---|---|---|
| TimechoDB 2.0.12.1 | Tree | verified | snapshot / incremental, manual ACK on a live session | >= 22.9.0 / >= 4.1.0 |
| TimechoDB 2.0.12.1 | Table | verified | snapshot / incremental, manual ACK on a live session | >= 22.9.0 / >= 4.1.0 |
| Apache IoTDB 2.0.11 | Tree | verified | compiled out of the release build; the node reports an explicit error | >= 22.9.0 / >= 4.1.0 |
| Apache IoTDB 2.0.11 | Table | verified | compiled out of the release build; the node reports an explicit error | >= 22.9.0 / >= 4.1.0 |
engines requires Node.js >= 22.9.0 and node-red.version requires Node-RED >= 4.1.0; validation ran on Node.js 22.22.1 / 24.19.0 with Node-RED 5.0.9. Node-RED 4.1 itself, other server versions and cluster deployments are not certified. Details in docs/compatibility.md.
Prerequisites: Node.js >= 22.9.0 and a Node-RED >= 4.1 installation. SQL-only use needs no compilation step.
git clone https://github.com/iotdb-ecosystem/node-red-node-iotdb.git
cd node-red-node-iotdb
npm ciInstall it into a Node-RED user directory and restart Node-RED:
cd ~/.node-red
npm install @timecho/node-red-node-iotdb@0.0.2The Java bridge behind the subscription node is built separately and CI does not build it:
export IOTDB_SUBSCRIPTION_CLASSPATH='/path/to/approved-sdk/lib/*'
npm run build:bridgenpm run build:bridge needs JDK 17 plus the server-matched official Java SDK and its dependencies, which are not vendored and not distributed with the npm package; a deployment that already ships the build product only needs a Java 17 runtime, while a missing build product makes the bridge start from Java source and therefore requires a JDK. Pin the tested package version and set Node-RED credentialSecret before production use.
npm ci
npm run check # syntax-check the node entry point and the lib modules
npm test # 21 unit and Node-RED tests, no server requiredCI runs exactly those three commands on Node.js 22.x and nothing else. Server-dependent suites are separate and never part of CI: npm run test:integration, npm run test:acceptance and npm run test:server-contract need IOTDB_TEST_HOST, IOTDB_TEST_PORT and IOTDB_TEST_PASSWORD, plus IOTDB_SUBSCRIPTION_CLASSPATH for native subscription. Integration runs create and clean up their own nr_test_ namespace and Topic resources; without a password the database tests skip, and a skip is not a pass.
| Field | Notes |
|---|---|
| Address and model | one iotdb-server per model; USE and SET SQL_DIALECT are rejected on a shared connection, so switch the configuration instead |
| Database | default database used by the operator |
| Credentials | username and password through Node-RED credentials, not the flow file |
| Timeout | bounds one SQL call; on expiry the connection is terminated and the write result is unknown to the caller |
| Queue limit | maximum pending-ACK batches before a consumer stops polling |
| Mode | auto, query or execute; statements that classifies ambiguously must be pinned manually |
SQL is executed verbatim - there is no placeholder substitution, so never concatenate untrusted input. Errors are delivered to the Catch path and msg.iotdb.error carries a stable classification; Complete fires after the operation has actually finished.
- Add an
iotdb-serverconfiguration node and fill in address, model and credentials. - Add an
iotdb-operatornode, select the server and inject SQL:
msg.topic = "SELECT temperature FROM root.factory.device01 LIMIT 100";
return msg;Queries return an array of row objects in msg.payload, non-query success returns {success:true}, and the rest of the input message is preserved.
- For native subscription add an
iotdb-consumernode, select an existing Topic and a stable groupId and consumerId:
// consumer output
{
topic: "temperature_topic",
payload: [{source: "root.factory.device01", timestamp: "1794133480573", values: {temperature: 25.5}}],
iotdb: {model: "tree", consumerGroupId: "alarms", consumerId: "worker1", ackToken: "opaque-token"}
}Default is manual ACK: keep msg.iotdb.ackToken and send it back to the same consumer after the downstream work succeeds (optionally with msg.iotdb.action = "ack"); an ACK input emits no data message. Multi-branch flows must merge first and acknowledge once. delivery mode commits after node.send(), which proves delivery to the flow, not downstream business success, so unacknowledged messages may be redelivered and the business logic must be idempotent.
Maintained by Timecho engineers in this organization; published to npm as @timecho/node-red-node-iotdb.
Apache-2.0, see LICENSE.