Hi,
I think the title is clear enough, but in summary :
When I run firebase serve --host 192.168.1.103 it serves the files on 192.168.1.103.
When I run firebase serve --host 192.168.1.103 --only functions it serves the https functions on localhost.
Thanks ! ;)
@theomathieubhvr I have the same issue. I am trying to set the host to 0.0.0.0 so docker binds it and I can get access to the functions outside from the container.
But localhost does not get binded in docker, just 0.0.0.0.
Have you had a work around?
Same here, functions get served just on localhost, this make quite impossibile to use inside a docker container.
Digging around the code I figured this out, it's because the firebase-tools is only setting the projectId as part of the functions-emulator config. This fixes it in my Dockerfile
ADD config.json /root/.config/configstore/@google-cloud/functions-emulator/config.json
and the config.json looks like this
{
"bindHost": "0.0.0.0"
}
You can change the 0.0.0.0 to any host you want, but this works for Docker.
For reference https://github.com/firebase/firebase-tools/blob/master/lib/serve/functions.js#L71 is the offending block, it needs to set the above parameter to the same as the --host command line parameter.
If you are running on your own local machine then you need to set it to the configstore folder for your respective OS on OS X it would be ~/.config/configstore/@google-cloud/functions-emulator/config.json.
Reference for the default config values https://github.com/GoogleCloudPlatform/cloud-functions-emulator/blob/master/src/defaults.json
Also note that the output will still show localhost instead of 0.0.0.0, but it does bind to the address you put in for the bindHost.
@Tivoli tried your solution on windows by adding the config.json in [nodejs]\node_modules\firebase-tools\node_modules\@google-cloud\functions-emulator but it doesn't seem to have any effect :(
@raduflp It goes into your home folder, not into the node_modules folder, there should be a .config in the windows home folder with a similar path.
found it in %USERPROFILE%\.config .... It times-out when it comes to displaying the success start message displaying the emulated function, but other than that is works.
thanks @Tivoli
+1 the same problem where.
I'm using react-native app to call to custom host, but firebase serve --host parameter doesn't make effect.
Is it possible this fix isn't released? I'm seeing same problem on firebase-tools 3.17.7....
I was able to workaround for now by modifying my config file as suggested by @Tivoli above.
@xaviershay It was released, can you run it again with the --debug flag and copy/paste the output here?
Here you go:
> firebase serve -o 192.168.221.129 --only functions --debug ori-tracker/web-ui master
[2018-03-26T21:14:48.157Z] ----------------------------------------------------------------------
[2018-03-26T21:14:48.160Z] Command: /usr/bin/nodejs /home/xavier/data/.npm-packages/bin/firebase serve -o 192.168.221.129 --only functions --debug
[2018-03-26T21:14:48.161Z] CLI Version: 3.17.7
[2018-03-26T21:14:48.161Z] Platform: linux
[2018-03-26T21:14:48.161Z] Node Version: v7.10.1
[2018-03-26T21:14:48.162Z] Time: Mon Mar 26 2018 14:14:48 GMT-0700 (PDT)
[2018-03-26T21:14:48.162Z] ----------------------------------------------------------------------
[2018-03-26T21:14:48.170Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-03-26T21:14:48.170Z] > authorizing via signed-in user
[2018-03-26T21:14:48.172Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/ori-tracker
Mon Mar 26 2018 14:14:48 GMT-0700 (PDT)
[2018-03-26T21:14:48.558Z] <<< HTTP RESPONSE 200 server=nginx, date=Mon, 26 Mar 2018 21:14:48 GMT, content-type=application/json; charset=utf-8, content-length=108, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-03-26T21:14:48.559Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/ori-tracker/tokens
Mon Mar 26 2018 14:14:48 GMT-0700 (PDT)
[2018-03-26T21:14:49.018Z] <<< HTTP RESPONSE 200 server=nginx, date=Mon, 26 Mar 2018 21:14:48 GMT, content-type=application/json; charset=utf-8, content-length=259, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-03-26T21:14:49.020Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/ori-tracker
Mon Mar 26 2018 14:14:49 GMT-0700 (PDT)
[2018-03-26T21:14:49.429Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 26 Mar 2018 21:14:49 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
=== Serving from '/home/xavier/data/Code/ori-tracker/web-ui'...
i functions: Preparing to emulate functions.
[2018-03-26T21:14:49.741Z] Fetching environment
[2018-03-26T21:14:49.742Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/511814877369:getServerAppConfig
Mon Mar 26 2018 14:14:49 GMT-0700 (PDT)
[2018-03-26T21:14:50.038Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 26 Mar 2018 21:14:50 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=hq=":443"; ma=2592000; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="42,41,39,35", accept-ranges=none, connection=close
[2018-03-26T21:14:50.040Z] Starting @google-cloud/functions-emulator
Warning: You're using Node.js v7.10.1 but Google Cloud Functions only supports v6.11.5.
[2018-03-26T21:14:51.083Z] Parsing function triggers
✔ functions: track: http://localhost:5000/ori-tracker/us-central1/track
info: User function triggered, starting execution
info: Execution took 7 ms, user function completed successfully
Trying to connect on that interface:
> curl http://localhost:5000/ori-tracker/us-central1/track
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /</pre>
</body>
</html>
> ifconfig | grep 192
inet 192.168.221.129 netmask 255.255.255.0 broadcast 192.168.221.255
> curl http://192.168.221.129:5000/ori-tracker/us-central1/track
curl: (7) Failed to connect to 192.168.221.129 port 5000: Connection refused
@xaviershay what happens if you curl on 5002? I know it says it started on 5000, but usually the default port is 5002 for functions.
You can use the host param on the command when you run the emulator:
Like this:firebase serve --only functions -o
It works well
It this will be tested/released this month?
Most helpful comment
Digging around the code I figured this out, it's because the firebase-tools is only setting the projectId as part of the functions-emulator config. This fixes it in my Dockerfile
ADD config.json /root/.config/configstore/@google-cloud/functions-emulator/config.jsonand the config.json looks like this
You can change the 0.0.0.0 to any host you want, but this works for Docker.
For reference https://github.com/firebase/firebase-tools/blob/master/lib/serve/functions.js#L71 is the offending block, it needs to set the above parameter to the same as the
--hostcommand line parameter.If you are running on your own local machine then you need to set it to the configstore folder for your respective OS on OS X it would be
~/.config/configstore/@google-cloud/functions-emulator/config.json.Reference for the default config values https://github.com/GoogleCloudPlatform/cloud-functions-emulator/blob/master/src/defaults.json