algolia / algoliasearch-helper-flutter

⚑️ Building block to create instant-search applications with Flutter
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/flutter/
Other
22 stars 15 forks source link

Algolia Timeout Exception #129

Closed SdxCoder closed 2 months ago

SdxCoder commented 6 months ago

Describe the bug πŸ›
From time to time we are facing this AlgoliaTimeoutException.

To Reproduce πŸ”
No clear steps to reproduce

Expected behavior πŸ’­
Connection timeout shouldn't be thrown.

Screenshots πŸ–₯

SC Screenshot 2024-03-11 at 9 01 36β€―AM

Environment:

Additional context

Error Log

#### Crashlytics - Stack trace #### Application: com.alhabibpharmacy.staging #### Platform: android #### Version: 1.0.193 (194) #### Issue: 01b5f1c27da7a2f1b52fd2c2d9bb02f2 #### Session: 65EEEA050020000105663FA47CE60191_DNE_7_v2 #### Date: Mon Mar 11 2024 05:50:08 GMT-0600 (Mountain Daylight Time) Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Exception: UnreachableHostsException{errors: [AlgoliaTimeoutException{error: DioException [connection timeout]: The request connection took longer than 0:00:02.000000 and it was aborted. To get rid of this exception, try raising the RequestOptions.connectTimeout above the duration of 0:00:02.000000 or improve the response time of the server.}, AlgoliaTimeoutException{error: DioException [connection timeout]: The request connection took longer than 0:00:02.000000 and it was aborted. To get rid of this exception, try raising the RequestOptions.connectTimeout above the duration of 0:00:02.000000 or improve the response time of the server.}, AlgoliaTimeoutException{error: DioException [connection timeout]: The request connection took longer than 0:00:02.000000 and it was aborted. To get rid of this exception, try raising the RequestOptions.connectTimeout above the duration of 0:00:02.000000 or improve the response time of the server.}, AlgoliaTimeoutException{error: DioException [connection timeout]: The request connection took longer than 0:00:02.000000 and it was aborted. To get rid of this exception, try raising the RequestOptions.connectTimeout above the duration of 0:00:02.000000 or improve the response time of the server.}]} at AlgoliaHitsSearchService._disjunctiveSearch(algolia_hits_search_service.dart:94)

SdxCoder commented 6 months ago

@aallam Can we have a look into this issue. Also algolia helper flutter is not exposing any way to change read and write timeout. May be we can update the api like this

 AlgoliaHitsSearchService({
    required String applicationID,
    required String apiKey,
    Duration connectTimeout = const Duration(seconds: 2),
    Duration writeTimeout = const Duration(seconds: 30),
    Duration readTimeout = const Duration(seconds: 5),
  }) : this.create(
          algolia.SearchClient(
            appId: applicationID,
            apiKey: apiKey,
            options: const algolia.ClientOptions(
              connectTimeout : connectTimeout,
              writeTimeout : writeTimeout,
              readTimeout : readTimeout,
              agentSegments: [
                algolia.AgentSegment(
                  value: 'algolia-helper-flutter',
                  version: libVersion,
                ),
              ],
            ),
          ),
        );
factory _HitsSearcher({
    required String applicationID,
    required String apiKey,
    required SearchState state,
    bool disjunctiveFacetingEnabled = true,
    Duration debounce = const Duration(milliseconds: 100),
    bool insights = false,
    Duration connectTimeout = const Duration(seconds: 2),
    Duration writeTimeout = const Duration(seconds: 30),
    Duration readTimeout = const Duration(seconds: 5),
  }) {
    final service = AlgoliaHitsSearchService(
      applicationID: applicationID,
      apiKey: apiKey,
      connectTimeout : connectTimeout,
      writeTimeout : writeTimeout,
      readTimeout : readTimeout,
    );

and then further exposing it to HitSearcher

cc @aallam

SdxCoder commented 6 months ago

We have another similar type but different exception. Please check this error log

Crashlytics - Stack trace

Application: com.alhabibpharmacy.staging

Platform: android

Version: 1.0.197 (198)

Issue: 01b5f1c27da7a2f1b52fd2c2d9bb02f2

Session: 65EF0E70008F000119BA74AAC8A25047_DNE_7_v2

Date: Mon Mar 11 2024 08:01:04 GMT-0600 (Mountain Daylight Time)

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Exception: UnreachableHostsException{errors: [AlgoliaIOException{error: DioException [connection error]: The connection errored: Failed host lookup: '-dsn.algolia.net' This indicates an error which most likely cannot be solved by the library. Error: SocketException: Failed host lookup: '-dsn.algolia.net' (OS Error: No address associated with hostname, errno = 7)}, AlgoliaIOException{error: DioException [connection error]: The connection errored: Failed host lookup: '-3.algolianet.com' This indicates an error which most likely cannot be solved by the library. Error: SocketException: Failed host lookup: '-3.algolianet.com' (OS Error: No address associated with hostname, errno = 7)}, AlgoliaIOException{error: DioException [connection error]: The connection errored: Failed host lookup: '-2.algolianet.com' This indicates an error which most likely cannot be solved by the library. Error: SocketException: Failed host lookup: '-2.algolianet.com' (OS Error: No address associated with hostname, errno = 7)}, AlgoliaIOException{error: DioException [connection error]: The connection errored: Failed host lookup: '-1.algolianet.com' This indicates an error which most likely cannot be solved by the library. Error: SocketException: Failed host lookup: '-1.algolianet.com' (OS Error: No address associated with hostname, errno = 7)}]} at AlgoliaHitsSearchService._disjunctiveSearch(algolia_hits_search_service.dart:94)

@aallam We are failing host lookup here. Can you please help, any solution for these errors?

ebsangam commented 4 months ago

It is problem with the core package. The timeout duration is only 2 sec by default. image

dhayab commented 2 months ago

Hi, we just published algolia_helper_flutter v1.1.0, which lets you customize client options from HitsSearcher.

SdxCoder commented 2 months ago

@dhayab these client options don't expose interceptor.