Influx 1.8 OSS with 2.0.0 client: InfluxDBException: statusCode = 401, code = null, message = null
BSBoatia opened this issue · comments
Describe the bug
Authentication fails, when trying to query a 1.8.5 based Influx instance with the 2.0.0 flutter client.
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: InfluxDBException: statusCode = 401, code = null, message = null #0 DefaultService._handleResponse package:influxdb_client/client/influxdb_client.dart:108 <asynchronous suspension> #1 QueryService._send package:influxdb_client/client/query_service.dart:80 <asynchronous suspension> #2 QueryService.query package:influxdb_client/client/query_service.dart:66 <asynchronous suspension> #3 _SysHealthState._loadHistoricalData package:screens/syshealth.dart:222 <asynchronous suspension>
To Reproduce
Steps to reproduce the behavior:
- Query data from a 1.8.5 influx db with auth-enabled = true
Expected behavior
The query to execute successfully as it does with influxdb_client: ^1.1.0
Specifications:
- Client Version: influxdb_client: ^2.0.0
- InfluxDB Version: 1.8.5
- Platform: Flutter (running client on iOS)
Additional context
The code is working fine with influxdb_client: ^1.1.0
Sample code I used works with client 1.1.0 but not 2.0.0
InfluxDBClient client = InfluxDBClient(
url: 'http://localhost:8086',
username: 'my_user',
password: 'my_password',
org: '',
bucket: 'my_db',
debug: false);
QueryService queryService = client.getQueryService();
String fluxQuery = '''
lat = from(bucket: "my_db")
|> range(start: -1d)
|> filter(fn: (r) => r["_measurement"] == "gps_pos")
|> filter(fn: (r) => r["_field"] == "lat")
|> limit(n:20)
long = from(bucket: "my_db")
|> range(start: -1d)
|> filter(fn: (r) => r["_measurement"] == "gps_pos")
|> filter(fn: (r) => r["_field"] == "long")
|> limit(n:20)
join(tables: {lat: lat, long: long}, on: ["_time"])
''';
Stream<FluxRecord> recordStream = await queryService.query(fluxQuery);
await recordStream.forEach((record) {
double lat = double.parse(record["_value_lat"].toString());
double long = double.parse(record["_value_long"].toString());
print('${record["_time"]} lat: $lat long: $long');
});
Hi @BSBoatia,
thanks for using our client.
I have prepared a fixed version within #26.
If you would like to use the fixed version of the client before release into pub.dev
, then you can import the library by:
dependencies:
influxdb_client:
git:
url: git@github.com:influxdata/influxdb-client-dart.git
ref: fix/authorization-v1
Regards