Skip to content
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

[FEATURE REQUEST] Add ability to set firebase base URLs so that official emulator can be used #154

Closed
creikey opened this issue Mar 7, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request
Projects

Comments

@creikey
Copy link

creikey commented Mar 7, 2021

Is your feature request related to a problem? Please describe.
Developing a game with the production firebase servers is not good practice, and the firebase emulator has more tools based around development (quickly generate fake google users as an example)

Describe the solution you'd like
A way to set the firebase root, auth, and store base URLs so that localhost can be used instead.

Describe alternatives you've considered
There is no alternative

Additional context
https://firebase.google.com/docs/emulator-suite

@creikey creikey added the enhancement New feature or request label Mar 7, 2021
@WolfgangSenff
Copy link
Collaborator

We can and should support this. I actually didn't realize it worked with the REST API. We'll get this into the next release.

@WolfgangSenff WolfgangSenff self-assigned this Mar 7, 2021
@WolfgangSenff WolfgangSenff added this to To do in Work via automation Mar 7, 2021
@nate-trojian
Copy link

I needed this feature for a project I am currently working on so I went and implemented it in my own fork of the project. While actually connecting to the emulators was easy enough, I discovered an issue in the Firebase emulators themselves that prevents SSE streaming from working.

When the HTTPSSEClient makes the request to the Realtime Database Emulator, it will never enter the STATUS_BODY state.
Screenshot showing underlying HTTPClient Status and the StreamPeer Connection Available Bytes.
SSE_Never_Reads_Body

It can be seen here that the StreamPeer does have the data, but because we never go to STATUS_BODY, we are not allowed to actually read it, so it remains in available bytes.

Similar screenshot showing successful production Realtime Database Streaming connection
SSE_Production_Success

HTTPClient Status mappings:
3 = Connecting
5 = Connected
6 = Requesting
7 = Body

This is due to the Realtime Database emulator not returning the proper Response Headers like production Realtime Database does for SSE streaming. Namely, it is missing a Connection: close header. I have made an issue in the Firebase Emulator repo detailing this.

As described in the issue above, the Emulator is missing any of three headers that inform the client as to when the transmission could be considered complete.
The Godot HTTPClient explicitly checks for these headers here:
https://github.com/godotengine/godot/blob/3.3/core/io/http_client.cpp#L492-L503.

One of these need to be present in order to have the conditions met to transition to the STATUS_BODY state, as seen here:
https://github.com/godotengine/godot/blob/3.3/core/io/http_client.cpp#L521-L531.

Because none of them are met, it always goes back to STATUS_CONNECTED, preventing the underlying data from being read.

@WolfgangSenff
Copy link
Collaborator

Care to open a PR to merge your changes, @nate-trojian? 😁

@WolfgangSenff
Copy link
Collaborator

Closed by #240. See #240 for more details.

Work automation moved this from To do to Done Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Work
Done
Development

No branches or pull requests

3 participants