influxdata / influxdata/influxdb

Connect to different IP

Open
#24,360 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

Hi. I a developing an APP with flutter, in this case I want to check if the connection to the first IP has been made correctly, make the query correctly; otherwise try to make the connection to the second IP. Next I leave you the code that I have implemented and it works correctly with the first IP, however when I select the second IP it does not give any error, but the query is not done, because it returns the empty variables.
```import 'package:influxdb_client/api.dart';
import '../Cuidador/screen_Paciente.dart';

class InfluxDBService {
late InfluxDBClient client;

// var url = 'http://192.168.72.11:8086'; // PC POM
var url = 'http://212.256.20.330:8086'; // PC POM

var token =
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var org = 'XXXXXXXXXXXXXXXXXX';
var bucket = 'XXXXXXXXXXXXXXXX';
InfluxDBService() {
//PC POM
client = InfluxDBClient(
url: url, // PC POM
token: token,
org: org,
bucket: bucket,
followRedirects: true,
maxRedirects: 5,
debug: true,
);
}

Future GetSteps(COD_PACIENTE_WEARABLE, startDateString, endDateString) async {
var startDate = DateTime.parse(startDateString);
var endDate = DateTime.parse(endDateString);
var queryService = client.getQueryService();
var StepsQuery = '''
from(bucket: "${bucket}")
|> range(start: ${startDate.toIso8601String()}, stop: ${endDate.toIso8601String()})
|> filter(fn: (r) => r["_measurement"] == "${COD_PACIENTE_WEARABLE}")
|> filter(fn: (r) => r["Data_type"] == "MISC")
|> filter(fn: (r) => r["Sensor_type"] == "Movement")
|> filter(fn: (r) => r["_field"] == "Steps")
''';
var StepsResponse = await queryService.query(StepsQuery);
// Convertir el Stream en una lista
var StepsRecords = await StepsResponse.toList();
client.close();
// Procesa los resultados y devuelve el nivel de la batería
// Procesar los resultados
var StepList = [];
for (var record in StepsRecords) {
var Step = record["_value"];
var timestampString = record["_time"];
var timestamp = DateTime.parse(timestampString).toLocal();

StepList.add(StepData(Step, timestamp));
}
StepList.sort((a, b) => b.timestamp.compareTo(a.timestamp));

return StepList;
}
}```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Flutter code with each URL value and inspect the result of queryService.query and StepsResponse.toList(). Compare the connection and query behavior for the two IP addresses. Done means the query returns the expected records when the second IP is selected.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
databases, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.