Could not connect to the server while connecting to function emulator running locally
functions().useFunctionsEmulator("http://localhost:5000")
Click To Expand
#### `package.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 ."
},
"dependencies": {
"@babel/preset-env": "^7.7.1",
"@react-native-community/geolocation": "^2.0.2",
"@react-native-firebase/app": "^6.0.4",
"@react-native-firebase/auth": "^6.0.4",
"@react-native-firebase/functions": "^6.0.4",
"braintree-web": "^3.57.0",
"native-base": "^2.13.8",
"react": "16.9.0",
"react-native": "0.61.4",
"react-native-animatable": "^1.3.3",
"react-native-gesture-handler": "^1.5.0",
"react-native-google-places-autocomplete": "^1.3.9",
"react-native-maps": "0.26.1",
"react-native-reanimated": "^1.4.0",
"react-native-screens": "^1.0.0-alpha.23",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3",
"react-navigation-tabs": "^2.5.6"
},
"devDependencies": {
"@babel/core": "^7.7.2",
"@babel/runtime": "^7.7.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.6.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.57.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
#### `firebase.json` for react-native-firebase v6:
# N/A
### iOS
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'user' do
# Pods for user
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/jscallinvoker', :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'
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'
target 'userTests' do
inherit! :search_paths
# Pods for testing
end
# React Native Maps dependencies
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
use_native_modules!
end
target 'user-tvOS' do
# Pods for user-tvOS
target 'user-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
#### `AppDelegate.m`:
```/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "AppDelegate.h"
#import </p>
</details>
---
### Android
<details><summary>Click To Expand</summary>
<p>
#### Have you converted to AndroidX?
<!--- Mark any options that apply below -->
- [ ] 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`:
```groovy
// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->
Click To Expand
**`react-native info` output:**
System:
OS: macOS 10.15.2
CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
Memory: 368.37 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.14.0 - /usr/local/bin/node
Yarn: 1.21.1 - ~/.yarn/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 11.3/11C29 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4
- **Platform that you're experiencing the issue on**:
- [x] iOS
- [ ] Android
- [x] **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:**
- `^6.0.4`
- **`Firebase` module(s) you're using that has the issue:**
- `e.g. Instance ID`
- **Are you using `TypeScript`?**
- `N`
Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]
React Native Firebase and Invertase on Twitter for updates on the library.for android, this is necessary for it to work for me
adb reverse tcp:5000 tcp:5000
Used it a bunch last night
for ios ?
i am working with real ios device
localhost is the phone. You have the emulator running on the phone? doubtful - you'll need the IP address of wherever the emulator is actually running - standard networking stuff I think? Android has the ability to do the port forwarding so you don't have to find IP addresses but for iOS get the IP of your laptop and try that
it is working on the simulator. But not in the real device.
I am running on a real iPhone through this command
npx react-native run-ios --device iPhone
simulator has no bearing on real phones for iOS, it's not like the android emulator where it is a real machine it is just a process running on your laptop sharing network etc, so localhost works. Try what I advised.
okay I'll try
not working
did you start the functions emulator so that it was listening on all interfaces, or is it still bound to localhost (and thus not available over the network?)
try https://stackoverflow.com/a/53584700/9910298 (add -o 0.0.0.0 to your functions emulator startup)
tried with
firebase serve -o 0.0.0.0
✔ functions: Emulator started at http://0.0.0.0:5000
Still, i am getting Error: Could not connect to the server.
just for follow-up, I'm not sure what is going on but I was working on the functions in my app anyway so I tried a few things - never could get the functions emulator to work from within a real ios device, even though it should have. Frustrating but I'm not sure what the cause is. Android works fine and that's good enough for my work purposes and I don't have time to investigate further, sorry
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.
If it can help any one, it works for me when I use the local address of the computer where the functions emulator run: http://192.168.1.13:5001 (in my case)
if (__DEV__) {
firebase.app().functions("europe-west1").useFunctionsEmulator(
"http://192.168.1.13:5001"
)
}
Tested with a real ios device, RN 0.60.5, rn-firebase 6.4.0
Hi @romchambe , did you get this working on a real physical iOS device? Passing the origin to functions(...) like that results in a type error for me.