#community-help

Resolving Import Error in Dart Client with Typesense

TLDR Vishal encountered an issue while populating auto schema with dart client, resulting in import exceptions. The problem was traced to the connectionTimeout property and was resolved after adjusting its settings.

Powered by Struct AI

2

3
22mo
Solved
Join the chat
Mar 06, 2022 (22 months ago)
Vishal
Photo of md5-f4674eb03153b1aebba04e8f3f14e4fe
Vishal
07:05 AM
Need help. I am using dart client to populate auto schema collection. During importJSONL I am getting the below exception; import finishes but the number of documents is 4 times the number of lines in the JSONL file. Typesense is running in a docker container and the Dart client is on a remote machine. No issues with Health API Call or creating the collection. If i remove try..catch there are 0 documents created; with tryโ€ฆcatch 4 times number of documents in JSONL

INFO: Importing JSONL documents.
SEVERE: TimeoutException after 0:00:02.000000: Future not completed```
/documents.dart/
Future<void> importJSONL(
Client client, [
// ignore: non_constant_identifier_names
String? JSONL,
]) async {
try {
final file = File('documents.jsonl');
logInfoln(log, 'Importing JSONL documents.');
log.fine(await client
.collection('test')
.documents
.importJSONL(JSONL ?? file.readAsStringSync()));
// await writePropagationDelay();
} on RequestException catch (e, stackTrace) {
log.severe(e.message, e, stackTrace);
} catch (e, stackTrace) {
log.severe(e, stackTrace);
}
}

/main.dart/
await collections.create2(client);
await documents.importJSONL(client);```
07:27
Vishal
07:27 AM
I think its related to connectionTimeout property. will update :)

final host = '', protocol = Protocol.http;
  final config = Configuration(
    // Replace with your configur
    // ation
    'xxx',
    nodes: {
      Node(
        protocol,
        host,
        port: 8108,
      )
    },
    numRetries: 3, // A total of 4 tries (1 original try + 3 retries)
    connectionTimeout: const Duration(seconds: 2),
07:31
Vishal
07:31 AM
Worked after editing the connetionTimeout Property ๐Ÿ™‚

2