firebase / flutterfire

πŸ”₯ A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.72k stars 3.97k forks source link

πŸ› [firebase_remote_config] Socket Exception is not returned specifically. #10982

Closed manikandanvgts closed 1 year ago

manikandanvgts commented 1 year ago

Bug report

Without internet connection socket exception is returned.Only getting this message internal remote config fetch error.

Output

https://github.com/firebase/flutterfire/assets/126783737/7336fb1a-7e8d-4ec2-93be-c1f7c94d152d

Steps to reproduce

Steps to reproduce the behavior:

  1. Just opening the app after it calls the remote config setup method and fetchActive method.
  2. Trun off internet connection or put airplane mode and again run the app.
  3. Will getting this exception message [firebase_remote_config/internal] internal remote config fetch error.

Expected behavior

Should be returned specific exception in flutter.

Sample project

class RemoteConfigServices {
  final AppConfigService? appConfig = Get.find<AppConfigService>();
  late FirebaseRemoteConfig remoteConfig;

  Future<void> config(String key) async {
    remoteConfig = FirebaseRemoteConfig.instance;
    try {
      await remoteConfig.setConfigSettings(RemoteConfigSettings(
          fetchTimeout: remoteConfig.settings.fetchTimeout,
          minimumFetchInterval: const Duration(minutes: 0)));
      await remoteConfig.fetchAndActivate();
      final value = getStringValue(key);
      appConfig!.setConfig(value);
      Logger.d(msg: 'Remote Config : $value');
    } catch (e, s) {
      debugPrint('remote exception : $e');
      Logger.e(msg: "Remote Config Fetch :", e: e, strackTrace: s);
    }
  }
  String getStringValue(String value) => remoteConfig.getString(value); 
}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
      name: "XXXXX", options: DefaultFirebaseOptions.currentPlatform);
  configureLogger();
  await DependencyInjection.init();
  final remoteConfig = Get.find<RemoteConfigServices>();
  await remoteConfig.config('XXXXXXXX');
  runApp(const MyApp());
}

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` flutter doctor Doctor summary (to see all details, run flutter doctor -v): [βœ“] Flutter (Channel stable, 3.10.0, on macOS 13.3.1 22E772610a darwin-arm64, locale en-IN) [βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [βœ“] Xcode - develop for iOS and macOS (Xcode 14.2) [βœ—] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [βœ“] Android Studio (version 2022.1) [βœ“] VS Code (version 1.77.1) [βœ“] Connected device (2 available) [βœ“] Network resources ! Doctor found issues in 1 category. ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 3.0.0 Flutter SDK 3.10.0 offline_app 1.0.0+1 dependencies: - cupertino_icons 1.0.5 - dartz 0.10.1 - equatable 2.0.5 [collection meta] - firebase_core 2.13.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_remote_config 4.2.1 [firebase_core firebase_core_platform_interface firebase_remote_config_platform_interface firebase_remote_config_web flutter] - floor 1.4.2 [collection floor_annotation flutter meta path sqflite sqflite_common_ffi sqlparser] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_inappwebview 5.7.2+3 [flutter] - get 4.6.5 [flutter] - intl 0.18.1 [clock meta path] - mixpanel_flutter 2.1.1 [flutter flutter_web_plugins js] - webview_flutter 4.2.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview] dev dependencies: - build_runner 2.4.2 [analyzer args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - floor_generator 1.4.2 [analyzer build build_config code_builder collection floor_annotation meta source_gen strings] - flutter_lints 2.0.1 [lints] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] transitive dependencies: - _fe_analyzer_shared 60.0.0 [meta] - _flutterfire_internals 1.3.1 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 5.12.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - args 2.4.1 - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - build 2.4.0 [analyzer async convert crypto glob logging meta package_config path] - build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 4.0.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.2.0 [analyzer async build collection crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.8 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.5.0 [built_collection collection fixnum meta] - characters 1.3.0 - charcode 1.3.1 - checked_yaml 2.0.3 [json_annotation source_span yaml] - clock 1.1.1 - code_builder 4.4.0 [built_collection built_value collection matcher meta] - collection 1.17.1 - convert 3.1.1 [typed_data] - crypto 3.0.3 [typed_data] - dart_style 2.3.1 [analyzer args path pub_semver source_span] - fake_async 1.3.1 [clock collection] - ffi 2.0.2 - file 6.1.4 [meta path] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.5.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_remote_config_platform_interface 1.4.1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_remote_config_web 1.4.1 [firebase_core firebase_core_web firebase_remote_config_platform_interface flutter flutter_web_plugins js] - fixnum 1.1.0 - floor_annotation 1.4.2 [meta] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - frontend_server_client 3.2.0 [async path] - glob 2.1.1 [async collection file path string_scanner] - graphs 2.3.0 [collection] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - json_annotation 4.8.1 [meta] - lints 2.1.0 - lists 1.0.1 [meta] - logging 1.1.1 - matcher 0.12.15 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.2.0 - meta 1.9.1 - mime 1.0.4 - package_config 2.1.0 [path] - path 1.8.3 - plugin_platform_interface 2.1.4 [meta] - pool 1.5.1 [async stack_trace] - pub_semver 2.1.4 [collection meta] - pubspec_parse 1.2.3 [checked_yaml collection json_annotation pub_semver yaml] - shelf 1.4.1 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.4 [shelf stream_channel web_socket_channel] - sky_engine 0.0.99 - source_gen 1.3.1 [analyzer async build dart_style glob path source_span yaml] - source_span 1.9.1 [collection path term_glyph] - sqflite 2.2.8+2 [flutter sqflite_common path] - sqflite_common 2.4.5 [synchronized path meta] - sqflite_common_ffi 2.2.5 [sqlite3 sqflite_common synchronized path meta] - sqlite3 1.11.1 [collection ffi js meta path] - sqlparser 0.27.0 [meta collection source_span charcode] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - strings 0.2.2 [characters unicode] - synchronized 3.1.0 - term_glyph 1.2.1 - test_api 0.5.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timing 1.0.1 [json_annotation] - typed_data 1.3.2 [collection] - unicode 0.3.1 [lists] - vector_math 2.1.4 - watcher 1.0.2 [async path] - web_socket_channel 2.4.0 [async crypto stream_channel] - webview_flutter_android 3.7.0 [flutter webview_flutter_platform_interface] - webview_flutter_platform_interface 2.3.0 [flutter meta plugin_platform_interface] - webview_flutter_wkwebview 3.4.3 [flutter path webview_flutter_platform_interface] - yaml 3.1.2 [collection source_span string_scanner] ```

darshankawar commented 1 year ago

Thanks for the report @manikandanvgts From the code sample you shared, I see that you are using third party package such as Get. Does the same error occur without using any community package ? You can try with plugin example and see if it gives same error or not ?

manikandanvgts commented 1 year ago

Hello @darshankawar, I'm using plugin example here. But i'm facing same issue. Getting exception : [firebase_remote_config/internal] internal remote config fetch error.

Output:
https://github.com/firebase/flutterfire/assets/126783737/478509ec-9808-45b7-b511-7bd4ddc3ed45

darshankawar commented 1 year ago

For Getting exception : [firebase_remote_config/internal] internal remote config fetch error., see if https://github.com/firebase/flutterfire/issues/6196 and underlying comments help.

manikandanvgts commented 1 year ago

Hi @darshankawar, According to this https://github.com/firebase/flutterfire/issues/6196 and underlying comments are not help me really. Without internet connection, i'm excepting socket exception to handle some functionality flows to my app.

This is android remote-config sdk code. Here i added the socket exception. https://github.com/manikandanvgts/firebase-android-sdk/blob/master/firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigFetchHttpClient.java#L210

Screenshot 2023-05-19 at 3 24 46 PM

Can you please check this.

darshankawar commented 1 year ago

That seems to be coming from native Android SDK. The flutterfire plugin is a thin wrapper around native SDKs.

google-oss-bot commented 1 year ago

Hey @manikandanvgts. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 1 year ago

Since there haven't been any recent updates here, I am going to close this issue.

@manikandanvgts if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.