[emulator:database] Long Polling fails when listening on 0.0.0.0 #2870
Open
Description
[REQUIRED] Environment info
firebase-tools: 8.16.2
Platform: Alpine Linux Docker image.
[REQUIRED] Test case
The companion repository with a test example and detailed readme available here: https://github.com/yuri-sergiichuk/firebase-rdb-docker-issue.
[REQUIRED] Steps to reproduce
- Start Dockerized Firebase RDB emulator with
host
being set to0.0.0.0
. - Try to read/write data from/to the emulator.
[REQUIRED] Expected behavior
You must be able to use the emulator via a forwarded port on localhost.
[REQUIRED] Actual behavior
The emulator handles the first .lp?start
request but redirects the caller to 0.0.0.0
and requests fail.
Here's a dump of requests being sent to the emulator from the web page:
---
http://localhost:54897/.lp?start=t&ser=75118654&cb=1&v=5&ns=fake-server
response:
function pLPCommand(c, a1, a2, a3, a4) {
parent.window["pLPCommand1"] && parent.window["pLPCommand1"](c, a1, a2, a3, a4);
}
function pRTLPCB(pN, data) {
parent.window["pRTLPCB1"] && parent.window["pRTLPCB1"](pN, data);
}
pLPCommand('start','1','nxExCrtfPv');
pRTLPCB(0,[{"t":"c","d":{"t":"h","d":{"ts":1606404821657,"v":"5","h":"0.0.0.0:54897","s":"kIsNLt22OP58UjyvSTXykWsJGyxPfWEA"}}}]);
---
http://0.0.0.0:54897/.lp?id=1&pw=nxExCrtfPv&ser=42313306&ns=fake-server
---
http://0.0.0.0:54897/.lp?dframe=t&id=1&pw=nxExCrtfPv&ns=fake-server
---
http://0.0.0.0:54897/.lp?id=1&pw=nxExCrtfPv&ser=42313307&ns=fake-server&seg0=0&ts0=1&d0=eyJ0IjoiZCIsImQiOnsiciI6MSwiYSI6InMiLCJiIjp7ImMiOnsic2RrLmpzLjgtMS0xIjoxfX19fQ..
---
http://0.0.0.0:54897/.lp?start=t&ser=96003070&cb=2&v=5&ls=kIsNLt22OP58UjyvSTXykWsJGyxPfWEA&ns=fake-server
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/root/.cache/firebase/emulators/firebase-database-emulator-v4.7.1.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
15:50:52.634 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
15:50:52.779 [main] INFO com.firebase.server.forge.App$ - Listening at 0.0.0.0:54897
[debug] [2020-11-26T15:50:51.160Z] ----------------------------------------------------------------------
[debug] [2020-11-26T15:50:51.163Z] Command: /usr/local/bin/node /usr/local/bin/firebase emulators:start --debug
[debug] [2020-11-26T15:50:51.163Z] CLI Version: 8.16.2
[debug] [2020-11-26T15:50:51.163Z] Platform: linux
[debug] [2020-11-26T15:50:51.163Z] Node Version: v14.15.1
[debug] [2020-11-26T15:50:51.164Z] Time: Thu Nov 26 2020 15:50:51 GMT+0000 (Coordinated Universal Time)
[debug] [2020-11-26T15:50:51.164Z] ----------------------------------------------------------------------
[debug] [2020-11-26T15:50:51.164Z]
[debug] [2020-11-26T15:50:51.165Z] >>> [apiv2][query] GET https://firebase-public.firebaseio.com/cli.json [none]
[debug] [2020-11-26T15:50:51.190Z] > 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"]
[debug] [2020-11-26T15:50:51.200Z] FirebaseError: Failed to authenticate, have you run firebase login?
[warn] ⚠ emulators: You are not currently authenticated so some features may not work correctly. Please run firebase login to authenticate the CLI.
[info] i emulators: Starting emulators: database {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: database"}}
[debug] [2020-11-26T15:50:51.206Z] database rules config: []
[warn] ⚠ database: Did not find a Realtime Database rules file specified in a firebase.json config file. The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration. {"metadata":{"emulator":{"name":"database"},"message":"Did not find a Realtime Database rules file specified in a firebase.json config file. The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration."}}
[debug] [2020-11-26T15:50:51.208Z] Ignoring unsupported arg: projectId {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: projectId"}}
[debug] [2020-11-26T15:50:51.209Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: auto_download"}}
[debug] [2020-11-26T15:50:51.209Z] Ignoring unsupported arg: rules {"metadata":{"emulator":{"name":"database"},"message":"Ignoring unsupported arg: rules"}}
[debug] [2020-11-26T15:50:51.209Z] Starting Database Emulator with command {"binary":"java","args":["-Duser.language=en","-jar","/root/.cache/firebase/emulators/firebase-database-emulator-v4.7.1.jar","--host","0.0.0.0","--port",54897],"optionalArgs":["port","host","functions_emulator_port","functions_emulator_host"],"joinArgs":false} {"metadata":{"emulator":{"name":"database"},"message":"Starting Database Emulator with command {\"binary\":\"java\",\"args\":[\"-Duser.language=en\",\"-jar\",\"/root/.cache/firebase/emulators/firebase-database-emulator-v4.7.1.jar\",\"--host\",\"0.0.0.0\",\"--port\",54897],\"optionalArgs\":[\"port\",\"host\",\"functions_emulator_port\",\"functions_emulator_host\"],\"joinArgs\":false}"}}
[info] i database: Database Emulator logging to database-debug.log {"metadata":{"emulator":{"name":"database"},"message":"Database Emulator logging to \u001b[1mdatabase-debug.log\u001b[22m"}}
[debug] [2020-11-26T15:50:51.691Z] <<< [apiv2][status] GET https://firebase-public.firebaseio.com/cli.json 200
[debug] [2020-11-26T15:50:51.691Z] <<< [apiv2][body] GET https://firebase-public.firebaseio.com/cli.json {"cloudBuildErrorAfter":1594252800000,"cloudBuildWarnAfter":1590019200000,"defaultNode10After":1594252800000,"minVersion":"3.0.5","node8DeploysDisabledAfter":1613390400000,"node8RuntimeDisabledAfter":1615809600000,"node8WarnAfter":1600128000000}
[debug] [2020-11-26T15:50:51.873Z] WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/root/.cache/firebase/emulators/firebase-database-emulator-v4.7.1.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
{"metadata":{"emulator":{"name":"database"},"message":"WARNING: An illegal reflective access operation has occurred\nWARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/root/.cache/firebase/emulators/firebase-database-emulator-v4.7.1.jar) to field sun.nio.ch.SelectorImpl.selectedKeys\nWARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil\nWARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations\nWARNING: All illegal access operations will be denied in a future release\n"}}
[debug] [2020-11-26T15:50:52.637Z] 15:50:52.634 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
{"metadata":{"emulator":{"name":"database"},"message":"15:50:52.634 [NamespaceSystem-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started\n"}}
[debug] [2020-11-26T15:50:52.780Z] 15:50:52.779 [main] INFO com.firebase.server.forge.App$ - Listening at 0.0.0.0:54897
{"metadata":{"emulator":{"name":"database"},"message":"15:50:52.779 [main] INFO com.firebase.server.forge.App$ - Listening at 0.0.0.0:54897\n"}}
[info]
┌──────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your apps. │
└──────────────────────────────────────────────────────────────┘
┌──────────┬───────────────┐
│ Emulator │ Host:Port │
├──────────┼───────────────┤
│ Database │ 0.0.0.0:54897 │
└──────────┴───────────────┘
Other reserved ports: