influxdata / influxdb-client-go

InfluxDB 2 Go Client
MIT License
609 stars 116 forks source link

i am not able to connect to influx db using serverless #402

Closed diwanatharv closed 5 months ago

diwanatharv commented 5 months ago

Specifications

Steps to reproduce

i am not able to influxdb serverless using this package i am getting this everytime 2024/06/22 17:47:04 Error connecting to InfluxDB: invalid character '<' looking for beginning of value but when i am using the v3 the latest package that is kind of giving me correct output

func init() { err := godotenv.Load(".env") if err != nil { log.Fatalf("Error loading .env file") }

influxDBURL := os.Getenv("INFLUXDB_URL")
token := os.Getenv("INFLUXDB_TOKEN")
InfluxDBOrg = os.Getenv("INFLUXDB_ORG")
InfluxDBBucket = os.Getenv("INFLUXDB_BUCKET")
client := NewInfluxDBClient(influxDBURL, token)
InfluxDBClient = client
fmt.Println("Connected to InfluxDB!")

}

func NewInfluxDBClient(url, token string) influxdb.Client { client := influxdb.NewClient(url, token) _, err := client.Health(context.Background()) if err != nil { log.Fatalf("Error connecting to InfluxDB: %v", err) } return client }

Expected behavior

i am not able to influxdb serverless using this package i am getting this everytime 2024/06/22 17:47:04 Error connecting to InfluxDB: invalid character '<' looking for beginning of value but when i am using the v3 the latest package that is kind of giving me correct output

func init() { err := godotenv.Load(".env") if err != nil { log.Fatalf("Error loading .env file") }

influxDBURL := os.Getenv("INFLUXDB_URL")
token := os.Getenv("INFLUXDB_TOKEN")
InfluxDBOrg = os.Getenv("INFLUXDB_ORG")
InfluxDBBucket = os.Getenv("INFLUXDB_BUCKET")
client := NewInfluxDBClient(influxDBURL, token)
InfluxDBClient = client
fmt.Println("Connected to InfluxDB!")

}

func NewInfluxDBClient(url, token string) influxdb.Client { client := influxdb.NewClient(url, token) _, err := client.Health(context.Background()) if err != nil { log.Fatalf("Error connecting to InfluxDB: %v", err) } return client } please help me

Actual behavior

i am not able to influxdb serverless using this package i am getting this everytime 2024/06/22 17:47:04 Error connecting to InfluxDB: invalid character '<' looking for beginning of value but when i am using the v3 the latest package that is kind of giving me correct output

func init() { err := godotenv.Load(".env") if err != nil { log.Fatalf("Error loading .env file") }

influxDBURL := os.Getenv("INFLUXDB_URL")
token := os.Getenv("INFLUXDB_TOKEN")
InfluxDBOrg = os.Getenv("INFLUXDB_ORG")
InfluxDBBucket = os.Getenv("INFLUXDB_BUCKET")
client := NewInfluxDBClient(influxDBURL, token)
InfluxDBClient = client
fmt.Println("Connected to InfluxDB!")

}

func NewInfluxDBClient(url, token string) influxdb.Client { client := influxdb.NewClient(url, token) _, err := client.Health(context.Background()) if err != nil { log.Fatalf("Error connecting to InfluxDB: %v", err) } return client }

Additional info

No response

bednar commented 5 months ago

Hi @diwanatharv,

Thank you for using our client. It appears that you are looking to connect to InfluxDB Serverless, also referred to as InfluxDB 3. To ensure you have the best experience and compatibility, please use the dedicated client designed for InfluxDB 3, which you can find at InfluxDB 3 Go Client.

Should you have any questions while setting up or using this client, or if there's anything else we can assist you with, please don't hesitate to reach out.

Best Regards