-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Long Polling is using the wrong hostname rather than the one specified in useEmulator
#4603
Comments
@aameen951 I believe this should be fixed in the latest version of the emulator. Can you please try it out and get back to us? |
Hey @aameen951. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Sorry for the late response, I wasn't able to test it at the time. The SDK I tested with is To summarize the problem: when the SDK switch from WebSocket to Long Polling, the first request is made to the correct host (the one provided by As an example: if I set the host for the database emulator in |
Sorry for the delay. Are you able to reproduce this with the |
If your |
Yes. I understand that. My first response comes back with Edit: I was able to reproduce the issue and am looking into it. Will report back soon. Thank you for your patience. |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
When using the emulator your are supposed to call
useEmulator
and pass it the hostname and the port number as follows:The database SDK is then supposed to use that hostname for connecting to the database.
The SDK has two connection methods: Websockets and Long Polling.
Websocket connection is working as expected but long polling is not.
The first request in long polling is connecting to the correct hostname as specified by
useEmulator
and its sending the following request:and the response is something like the following:
All following requests are using the hostname that arrived in the previous response which is 'localhost', and they are all failing because localhost refers to the wrong computer when used on the client.
This problem will only happen if you try to connect to the database from a different computer. Using the same computer it would still work because 'localhost' is referring to both the client and the database.
The fix for this could be to ignore the incoming hostname and port number if using an emulator.
Steps to reproduce:
0.0.0.0
to listen for connections on all interfaces by setting the host infirebase.json
:database().useEmulator(hostname, 9000)
./.lp
will succeed and following requests will fail.Relevant Code:
This is the code that changes the hostname based on the first response:
firebase-js-sdk/packages/database/src/core/RepoManager.ts
Lines 70 to 88 in b6080a8
The text was updated successfully, but these errors were encountered: