taosdata / taosdata/TDengine

nodeV16- nestjs @tdengine/rest connection failed,error code:TypeError: Only HTTP(S) protocols are supported

Open
#23,943 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C
Stars
25.1k
Forks
5k
Avg merge
4d 59m
Merged PRs (30d)
7

Description

import { Injectable } from "@nestjs/common";
import { connect, Options } from "@tdengine/rest";

@Injectable()
export class TdengineServices {
private readonly options: Options;
private readonly connection: any; // 假设连接对象的类型为 any,实际上应该是具体的类型

constructor() {
    this.options = {
        host: "localhost",
        path: "/rest/sql",
        port: 6041,
        passwd: "taosdata",
        user: "root"
    } as Options;
    this.connection = connect(this.options);

    if (this.connection.isConnected) {
        console.log("连接成功")
    } else {
        console.log("连接失败")
    }

   this.sqlInsert()
}

async sqlInsert() {
    let cursor = this.connection.cursor(); // 获取游标
    try {
        let res = await cursor.query('CREATE DATABASE power');
        res = await cursor.query('CREATE STABLE power.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int)');
        res = await cursor.query('INSERT INTO power.d1001 USING power.meters TAGS ("California.SanFrancisco", 2) VALUES (NOW, 10.2, 219, 0.32)');
        console.log("res.getResult()", res.getResult());
    } catch (err) {
        console.log(err);
    }
}

}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the NestJS example with Node v16 and the @tdengine/rest connect options shown in the issue, then trace where the HTTP(S) URL is assembled before the TypeError. The report names no repository file or test; done means identifying and documenting or correcting the connection configuration so the REST connection and sample queries run successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, sql, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.