algolia / algolia/algoliasearch-client-dart

[bug]: DioException (DioException [connection timeout]: The request connection took longer than 0:00:10.000000 and it was aborted. To get rid of this exception, try raising the RequestOptions.connectTimeout above the duration of 0:00:10.000000

Open
#22 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Dart
Stars
17
Forks
10
PR merge metrics
No merged PRs in 30d

Description

### Description

Complete Exception: DioException (DioException [connection timeout]: The request connection took longer than 0:00:10.000000 and it was aborted. To get rid of this exception, try raising the RequestOptions.connectTimeout above the duration of 0:00:10.000000 or improve the response time of the server.

Below is my code:

```
import 'package:algoliasearch/algoliasearch.dart';

final client = SearchClient(
appId: '',
apiKey: '',
options: ClientOptions(
readTimeout: const Duration(seconds: 100),
connectTimeout: const Duration(seconds: 100),
),
);

final customerIndex = 'users';

Future retrieveCustomers() async {
try {
toggleIsFetching();
final queryHits = SearchForHits(
indexName: customerIndex,
query: '',
filters: 'type:customer',
hitsPerPage: 5,
);
final responseHits = await client.searchIndex(request: queryHits);

allCustomerList = responseHits.hits.map((hit) {
final data = Map.from(hit);
return CustomerModel.fromMap(data);
}).toList();
applyFilters();
} catch (e, stackTrace) {
log(' Unknown error: $e');
log('Stack trace: $stackTrace');
} finally {
toggleIsFetching();
}
}
```

Expected outcome: Data fetched without exception
Actual outcome: Data fetched with exception

I have tried increasing the connectTimeout at about 100, this error is replaced by the following error:

DioException (DioException [receive timeout]: The request took longer than 0:00:05.000000 to receive data. It was aborted. To get rid of this exception, try raising the RequestOptions.receiveTimeout above the duration of 0:00:05.000000 or improve the response time of the server.)

So, I increase the read timeout. but now I'm just getting a socket exception with no explanation. No exception reason showing even though I've uped both read and connect timeout to 5 minutes

This was my ping to algolia in case its helpful at all:

PING c16-uk-2.algolia.net (23.106.238.161): 56 data bytes
64 bytes from 23.106.238.161: icmp_seq=0 ttl=47 time=153.217 ms
64 bytes from 23.106.238.161: icmp_seq=1 ttl=47 time=153.907 ms
64 bytes from 23.106.238.161: icmp_seq=2 ttl=47 time=154.144 ms
64 bytes from 23.106.238.161: icmp_seq=3 ttl=47 time=152.327 ms
64 bytes from 23.106.238.161: icmp_seq=4 ttl=47 time=153.422 ms
64 bytes from 23.106.238.161: icmp_seq=5 ttl=47 time=206.085 ms
^[[A^[[A^[[A^[[A64 bytes from 23.106.238.161: icmp_seq=6 ttl=47 time=153.258 ms
64 bytes from 23.106.238.161: icmp_seq=7 ttl=47 time=346.621 ms
64 bytes from 23.106.238.161: icmp_seq=8 ttl=47 time=152.813 ms
64 bytes from 23.106.238.161: icmp_seq=9 ttl=47 time=177.608 ms
64 bytes from 23.106.238.161: icmp_seq=10 ttl=47 time=154.339 ms
64 bytes from 23.106.238.161: icmp_seq=11 ttl=47 time=152.963 ms
64 bytes from 23.106.238.161: icmp_seq=12 ttl=47 time=153.770 ms

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.32.1, on macOS 12.7.6 21H1320 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 14.2)
! Flutter recommends a minimum Xcode version of 15.
Download the latest version or update via the Mac App Store.
! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.101.0)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 1 category.

### Client

All

### Version

1.34.0

### Relevant log output

```shell

```

Contributor guide

No contributing guide indexed for this repository

Research direction

The report provides no repository file, test, or entry point; start by reproducing the shown SearchClient.searchIndex request with the reported ClientOptions values. Compare the resulting timeout and socket errors with the client's documented behavior and existing tests, if present. Done means the failure is reproducible and its handling or configuration behavior is covered by a verified change.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
api, networking
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.