React-native-firebase: Could not reach Cloud Firestore backend. iOS device

Created on 18 Jun 2020  路  14Comments  路  Source: invertase/react-native-firebase

Issue




While getting a document on firestore in the iOS i keep receiving this error:
Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: failed to connect to all addresses

It was fetching normally using the simulator, but when i was going to the iOS device the problem was happening.

After I created this post and tried to use the simulator with a realtime fetch the samething happens.
This error is shown on the xcode run output log

``2020-06-18 19:06:56.087755-0400 ZupLog[78675:15205014] [] nw_socket_handle_socket_event [C7.1:1] Socket SO_ERROR [61: Connection refused] 2020-06-18 19:06:56.090127-0400 ZupLog[78675:15205014] [] nw_socket_handle_socket_event [C7.2:1] Socket SO_ERROR [61: Connection refused] 2020-06-18 19:06:56.090748-0400 ZupLog[78675:15205022] [] nw_connection_get_connected_socket [C7] Client called nw_connection_get_connected_socket on unconnected nw_connection 2020-06-18 19:06:56.091161-0400 ZupLog[78675:15205022] TCP Conn 0x6000032c5140 Failed : error 0:61 [61] 2020-06-18 19:06:56.214 [warn][tid:com.facebook.react.JavaScript] The native module for Flipper seems unavailable. Please verify thatreact-native-flipperis installed as yarn dependency to your project and, for iOS, thatpod installis run in theiosdirectory. 2020-06-18 19:06:56.957 [info][tid:com.facebook.react.JavaScript] Running "user" with {"rootTag":1,"initialProps":{}} 2020-06-18 19:06:56.809130-0400 ZupLog[78675:15204998] 6.25.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add[FIRApp configure];(FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.
2020-06-18 19:06:57.753 [info][tid:main][RNGestureHandlerManager.m:136] [GESTURE HANDLER] Initialize gesture handler for root view ; layer = >
2020-06-18 19:06:58.063220-0400 ZupLog[78675:15204999] 6.25.0 - [Firebase/Firestore][I-FST000001] Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: failed to connect to all addresses
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.



---

## Project Files

### Javascript

<details><summary>Click To Expand</summary>
<p>

#### `package.json`:

```json{
  "name": "user",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
    "react-native": "react-native"
  },
  "dependencies": {
    "@expo/react-native-action-sheet": "^3.7.0",
    "@react-native-community/async-storage": "^1.10.0",
    "@react-native-community/datetimepicker": "^2.4.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-firebase/analytics": "^7.1.3",
    "@react-native-firebase/app": "^7.2.0",
    "@react-native-firebase/auth": "^8.0.4",
    "@react-native-firebase/crashlytics": "^7.1.4",
    "@react-native-firebase/firestore": "^7.1.5",
    "@react-native-firebase/functions": "^7.1.3",
    "@react-native-firebase/storage": "^7.1.3",
    "@react-navigation/bottom-tabs": "^5.4.1",
    "@react-navigation/drawer": "^5.7.1",
    "@react-navigation/native": "^5.1.5",
    "@react-navigation/stack": "^5.2.10",
    "@unform/core": "2.1.0",
    "@unform/mobile": "2.1.0",
    "appcenter": "^3.0.2",
    "appcenter-analytics": "^3.0.2",
    "appcenter-crashes": "^3.0.2",
    "axios": "^0.19.2",
    "date-fns": "^2.14.0",
    "eslint-plugin-react": "^7.19.0",
    "expo-camera": "^8.2.0",
    "expo-image-picker": "^8.1.0",
    "expo-permissions": "^8.1.0",
    "immer": "^6.0.5",
    "lint-staged": "^10.2.2",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-bootsplash": "^2.2.4",
    "react-native-flash-message": "^0.1.15",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-get-random-values": "^1.4.0",
    "react-native-google-places-autocomplete": "^1.7.1",
    "react-native-image-progress": "^1.1.1",
    "react-native-masked-text": "^1.13.0",
    "react-native-modal": "^11.5.6",
    "react-native-reanimated": "^1.8.0",
    "react-native-safe-area-context": "^0.7.3",
    "react-native-screens": "^2.4.0",
    "react-native-shimmer": "^0.6.0",
    "react-native-unimodules": "^0.9.1",
    "react-native-vector-icons": "^6.6.0",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.1.3",
    "shared": "0.0.1",
    "styled-components": "^5.1.0",
    "typescript": "^3.8.3",
    "uuid": "^8.1.0",
    "yup": "^0.28.5"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@types/jest": "^24.0.24",
    "@types/react-native": "^0.62.0",
    "@types/react-native-vector-icons": "^6.4.5",
    "@types/react-redux": "^7.1.8",
    "@types/react-test-renderer": "16.9.2",
    "@types/styled-components": "^5.1.0",
    "@types/uuid": "^8.0.0",
    "@types/yup": "^0.28.0",
    "@typescript-eslint/eslint-plugin": "^2.31.0",
    "@typescript-eslint/parser": "^2.27.0",
    "babel-jest": "^24.9.0",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.58.0",
    "react-test-renderer": "16.11.0",
    "reactotron-redux-saga": "^4.2.3",
    "typescript": "^3.8.3"
  },
  "jest": {
    "preset": "react-native",
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx",
      "json",
      "node"
    ]
  }
}

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:

platform :ios, '10.0'
require_relative '../../../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../../../node_modules/react-native-unimodules/cocoapods.rb'

def add_flipper_pods!(versions = {})
  versions['Flipper'] ||= '~> 0.33.1'
  versions['DoubleConversion'] ||= '1.1.7'
  versions['Flipper-Folly'] ||= '~> 2.1'
  versions['Flipper-Glog'] ||= '0.3.6'
  versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
  versions['Flipper-RSocket'] ||= '~> 1.0'

  pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configuration => 'Debug'

  # List all transitive dependencies for FlipperKit pods
  # to avoid them being linked in Release builds
  pod 'Flipper', versions['Flipper'], :configuration => 'Debug'
  pod 'Flipper-DoubleConversion', versions['DoubleConversion'], :configuration => 'Debug'
  pod 'Flipper-Folly', versions['Flipper-Folly'], :configuration => 'Debug'
  pod 'Flipper-Glog', versions['Flipper-Glog'], :configuration => 'Debug'
  pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configuration => 'Debug'
  pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configuration => 'Debug'
  pod 'FlipperKit/Core', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/CppBridge', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FBDefines', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configuration => 'Debug'
  pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
end

# Post Install processing for Flipper
def flipper_post_install(installer)
  installer.pods_project.targets.each do |target|
    if target.name == 'YogaKit'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.1'
      end
    end
  end
end

target 'user' do
  # Pods for user
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '6.25.0'
  pod 'Firebase/Analytics'
  pod 'FBLazyVector', :path => "../../../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../../../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../../../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../../../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../../../node_modules/react-native/'
  pod 'React-Core', :path => '../../../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../../../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../../../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../../../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../../../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../../../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../../../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../../../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../../../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../../../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../../../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../../../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../../../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../../../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../../../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../../../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../../../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/callinvoker', :path => "../../../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../../../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../../../node_modules/react-native/ReactCommon/yoga', :modular_headers => true

  pod 'DoubleConversion', :podspec => '../../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../../../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../../../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # pre_install do |installer|
  #   Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
  # end

  target 'userTests' do
    inherit! :complete
    # Pods for testing
  end

  use_native_modules!
  use_unimodules!(modules_paths: ['../../../node_modules'])

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  add_flipper_pods!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'user-tvOS' do
  # Pods for user-tvOS

  target 'user-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end
#### `AppDelegate.m`:
```ruby
#import <Firebase.h>
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>

#import <AppCenterReactNative.h>
#import <AppCenterReactNativeAnalytics.h>
#import <AppCenterReactNativeCrashes.h>
#import <AppCenterReactNative.h>
#import <AppCenterReactNativeAnalytics.h>
#import <AppCenterReactNativeCrashes.h>

#import "RNBootSplash.h"
#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>

#if DEBUG
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>

static void InitializeFlipper(UIApplication *application) {
  FlipperClient *client = [FlipperClient sharedClient];
  SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
  [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
  [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
  [client addPlugin:[FlipperKitReactPlugin new]];
  [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
  [client start];
}
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
  [AppCenterReactNative register];
  [AppCenterReactNativeAnalytics registerWithInitiallyEnabled:true];
  [AppCenterReactNativeCrashes registerWithAutomaticProcessing];
#if DEBUG
  InitializeFlipper(application);
#endif
  self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"user"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  [RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
  NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
    // You can inject any extra modules that you would like here, more information at:
    // https://facebook.github.io/react-native/docs/native-modules-ios.html#dependency-injection
  return extraModules;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end
```


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:

// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->


Environment

Click To Expand

**`react-native info` output:** I runned npx react-native info

System:
    OS: macOS 10.15.4
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Memory: 1.40 GB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.12.0 - ~/.nvm/versions/node/v13.12.0/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v13.12.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 27, 28
      Build Tools: 27.0.3, 28.0.3
      Android NDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 11.5/11E608c - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_181 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages: 
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
- **Platform that you're experiencing the issue on**: - [x] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `^7.2.0` - **`Firebase` module(s) you're using that has the issue:** - `Firestore` - **Are you using `TypeScript`?** - `Y` & `^3.8.3`




Bug Firestore Stale Waiting for User Response

All 14 comments

I'm curious about that AppDelegate.m. Does it have the FIRApp configure? https://rnfirebase.io/#3-ios-setup - you didn't include it

This is a most strange situation, seems like a total failure to integrate - but in a subtle way! You might try examining the output of this throwaway-sample-generator to compare https://github.com/mikehardy/rnfbdemo/blob/master/make-demo-v6.sh (or just reading it - it is not long and fully commented)

Oh, i forgot.
Just added to the main comment. Also i removed the
if ([FIRApp defaultApp] == nil) { and just let the [FIRApp configure]; alone over there, nothing changed.
@mikehardy

Got it working now. I just completely deleted the app from my device and reinstalled it. Apparently it solved. Wondering why this happened because it was working in the beginning then it stopped and now i needed to do this complete reinstall to get it working

Why closed? This is still an issue. Happened again in a device that was working and for no reason stopped... It seems to be an issue.

It seems that if you change ANYTHING on the firestore settings through the JS you need to complete delete the app an reinstall it again. Is that the correct behaviour?

a valid question, I'm not familiar with how the JS settings work but if they for example went into async storage or something and there was bogus caching it would rhyme with this. No idea what's really happening though or even where in the stack the issue would be (upstream in Firebase SDKs, here, ?)

Same question here, as I am more an RN developer and not an Swift/Java developer I posted this here to get in a discussion about this. I am not sure if this is an RNFirebase issue, a Firebase iOS SDK or ...

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

Still needs attention

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

Sorry this has languished. If I understand correctly:

  • if you configure things correctly for firestore normal usage, things work
  • if you reconfigure to use the emulator, things do not work until you delete / reinstall
  • if you reconfigure from emulator to use normal (cloud) again, things do not work until delete / reinstall

Is that correct?

Then what I need to know in order to cleanly reproduce this is:

  • what exactly is reconfigured when switching ?

That way I/we can construct a real test that causes the issue every time, then we can fix.

I dont know if the bug still occurs but yes, that 3 points are right. About the question about what exactly is reconfigured I dont remember exactly but I was just trying to setup the emulator in my project (I still dont use it because of this bug and because my project is not yet on production).

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

romreed picture romreed  路  3Comments

rtman picture rtman  路  3Comments

n-scope picture n-scope  路  3Comments

jonaseck2 picture jonaseck2  路  3Comments

callmejm picture callmejm  路  3Comments