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.62k stars 3.95k forks source link

🐛 [firebase_storage] SocketException: Failed host lookup: 'firebasestorage.googleapis.com' #6508

Closed kuromukira closed 3 years ago

kuromukira commented 3 years ago

Bug report

Describe the bug I've been getting this error non-stop in crashlytics for a few months now. Users are complaining that they are not able to upload any images and complete the sign-up process. This causes a lot of frustrations to existing customers and a loss of interest for potential customers.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a new Flutter project
  2. Just add firebase_storage as a plugin
  3. Try and upload an image

Expected behavior

This should not happen in the first place.

Sample project

Project is a private repository of a business. I don't think I can provide one.


Additional context

NA

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale en-PH) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.1) [✓] VS Code (version 1.57.1) [✓] Connected device (1 available) ! Error: iPHONE is not connected. Xcode will continue when iPHONE is connected. (code -13) • No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.13.3 Flutter SDK 2.2.2 myApp 1.8.0 dependencies: - badges 2.0.1 [flutter] - bottom_navy_bar 6.0.0 [flutter] - bubble 1.2.1 [flutter] - device_info_plus 2.0.1 [flutter device_info_plus_platform_interface device_info_plus_linux device_info_plus_macos device_info_plus_web device_info_plus_windows] - file_picker 3.0.3 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface] - firebase_analytics 8.1.2 [firebase_analytics_platform_interface firebase_analytics_web firebase_core flutter meta] - firebase_auth 1.4.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.3.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 2.0.6 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 10.0.2 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_storage 8.1.3 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_local_notifications 6.0.0 [flutter flutter_local_notifications_platform_interface platform timezone] - font_awesome_flutter 9.1.0 [flutter] - get_it 7.1.3 [async collection] - myApp_core 1.8.0 [flutter connectivity_plus device_info_plus equatable firebase_analytics firebase_auth firebase_core firebase_crashlytics firebase_messaging firebase_storage flutter_local_notifications font_awesome_flutter get_it google_api_availability hive hive_flutter http intl logger path provider tuple] - myApp_ui 1.8.0 [flutter myApp_core badges cached_network_image camera dropdown_search flutter_spinkit flutter_svg loading_overlay octo_image page_transition pull_to_refresh url_launcher] - page_transition 2.0.2 [flutter] - pinput 1.2.0 [flutter] - provider 5.0.0 [collection flutter nested] - qr_flutter 4.0.0 [flutter qr] - smooth_page_indicator 0.3.0-nullsafety.0 [flutter] - tuple 2.0.0 [quiver] - url_launcher 6.0.7 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] dev dependencies: - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] - import_sorter 4.6.0 [args tint yaml] transitive dependencies: - args 2.1.1 - async 2.6.1 [meta collection] - boolean_selector 2.1.0 [source_span string_scanner] - cached_network_image 3.0.0 [flutter flutter_cache_manager octo_image] - camera 0.8.1+3 [camera_platform_interface flutter pedantic quiver] - camera_platform_interface 2.0.1 [flutter meta plugin_platform_interface cross_file stream_transform] - characters 1.1.0 - charcode 1.2.0 - clock 1.1.0 - collection 1.15.0 - connectivity_plus 1.0.4 [flutter meta connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows] - connectivity_plus_linux 1.0.3 [flutter connectivity_plus_platform_interface dbus meta] - connectivity_plus_macos 1.0.2 [connectivity_plus_platform_interface flutter] - connectivity_plus_platform_interface 1.0.2 [flutter meta plugin_platform_interface] - connectivity_plus_web 1.0.2 [connectivity_plus_platform_interface flutter_web_plugins flutter] - connectivity_plus_windows 1.0.2 [connectivity_plus_platform_interface flutter] - cross_file 0.3.1+1 [flutter meta] - crypto 3.0.1 [collection typed_data] - dbus 0.5.2 [args meta pedantic xml] - device_info_plus_linux 2.0.0 [device_info_plus_platform_interface file flutter meta] - device_info_plus_macos 2.0.0 [device_info_plus_platform_interface flutter] - device_info_plus_platform_interface 2.0.0 [flutter meta plugin_platform_interface] - device_info_plus_web 2.0.0 [device_info_plus_platform_interface flutter_web_plugins flutter] - device_info_plus_windows 2.0.0 [device_info_plus_platform_interface ffi flutter win32] - dropdown_search 0.6.3 [flutter] - equatable 2.0.3 [collection meta] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase 9.0.1 [http http_parser js] - firebase_analytics_platform_interface 2.0.1 [flutter meta] - firebase_analytics_web 0.3.0+1 [firebase firebase_analytics_platform_interface flutter flutter_web_plugins meta] - firebase_auth_platform_interface 4.3.1 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 1.3.1 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.0.6 [collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 3.0.2 [firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 2.0.2 [firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 2.1.2 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 1.1.2 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.1.2 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_local_notifications_platform_interface 4.0.0 [flutter plugin_platform_interface] - flutter_plugin_android_lifecycle 2.0.2 [flutter] - flutter_spinkit 5.0.0 [flutter] - flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - google_api_availability 3.0.1 [flutter meta] - hive 2.0.4 [meta crypto] - hive_flutter 1.1.0 [flutter hive path_provider path] - http 0.13.3 [async http_parser meta path pedantic] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - intl 0.17.0 [clock path] - js 0.6.3 - loading_overlay 0.3.0 [flutter] - logger 1.0.0 - matcher 0.12.10 [stack_trace] - meta 1.3.0 - nested 1.0.0 [flutter] - octo_image 1.0.0+1 [flutter flutter_blurhash] - path 1.8.0 - path_drawing 0.5.1 [vector_math meta path_parsing flutter] - path_parsing 0.2.1 [vector_math meta] - path_provider 2.0.2 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 2.0.0 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.11.1 - petitparser 4.1.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - process 4.2.1 [file path platform] - pull_to_refresh 2.0.0 [flutter] - qr 2.1.0 [meta] - quiver 3.0.1 [matcher] - rxdart 0.27.1 - sky_engine 0.0.99 - source_span 1.8.1 [collection path term_glyph] - sqflite 2.0.0+3 [flutter sqflite_common path] - sqflite_common 2.0.0+2 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - stream_transform 2.0.0 - string_scanner 1.1.0 [charcode source_span] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.3.0 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.7.0 [path] - tint 2.0.0 - typed_data 1.3.0 [collection] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.3 [flutter plugin_platform_interface] - url_launcher_web 2.0.1 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.0 [flutter] - uuid 3.0.4 [crypto] - vector_math 2.1.0 - win32 2.2.4 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.1.2 [collection meta petitparser] - yaml 3.1.0 [collection source_span string_scanner] ```

darshankawar commented 3 years ago

@kuromukira Does the error replicate locally if you try the steps to replicate ? If possible, can you provide entire crashlytics log that may contain additional info / details around the exception ?

Thanks.

kuromukira commented 3 years ago

@darshankawar

This bug however, cannot be reproduced in my local machine. Both running in Simulator / Android Emulator or an actual iOS / Android device.

Here are the logs from the latest crashlytics entry

flutter_error_reason
thrown SocketException: Failed host lookup: 'firebasestorage.googleapis.com' (OS Error: nodename nor servname provided, or not known, errno = 8). Error thrown Instance of 'ErrorDescription'.flutter_error_reason
thrown SocketException: Failed host lookup: 'firebasestorage.googleapis.com' (OS Error: nodename nor servname provided, or not known, errno = 8). Error thrown Instance of 'ErrorDescription'.

flutter_error_exception
SocketException: Failed host lookup: 'firebasestorage.googleapis.com' (OS Error: nodename nor servname provided, or not known, errno = 8)
flutter_error_reason
thrown SocketException: OS Error: Connection reset by peer, errno = 54, address = firebasestorage.googleapis.com, port = 49739. Error thrown Instance of 'ErrorDescription'.

flutter_error_exception
SocketException: OS Error: Connection reset by peer, errno = 54, address = firebasestorage.googleapis.com, port = 49739
flutter_error_reason
thrown Connection closed before full header was received. Error thrown Instance of 'ErrorDescription'.

flutter_error_exception
Connection closed before full header was received
darshankawar commented 3 years ago

@kuromukira Since your app is already in production, I am assuming the internet and access_network_state permissions are already in place in required manifest files.

The error: OS Error: nodename nor servname provided, or not known, errno = 8 usually indicates that the hostname is not written and may have to do with the DNS configuration.

Having said that, it doesn't seem to be specific to firebase_storage or for that matter, any firebase plugin, but seems to be related to DNS lookup failure.

Without a code sample or reproducible use case, it's hard to tell, but if you are doing any I/O operations or network calls using http in your app, the calls can fail or timeout, so you need to catch it gracefully.

Since this case is not locally replicable, we won't be able to make it actionable. I suggest you to ask this question on StackOverflow to get more insights on how the error can be handled, irrespective of using / not using firebase plugins.

Closing from here. If you disagree, or come up with a replicable use case that triggers this behavior using firebase_storage plugin, write in comments and I'll reopen it.

kuromukira commented 3 years ago

@darshankawar Thanks for the info. I'll implement a fallback in case the Firebase Storage uploads encounter an error (any).