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

Unable to connect to realtime db hosted in europe west #415

Closed
Jo3116 opened this issue Jan 13, 2021 · 3 comments · Fixed by #423
Closed

Unable to connect to realtime db hosted in europe west #415

Jo3116 opened this issue Jan 13, 2021 · 3 comments · Fixed by #423

Comments

@Jo3116
Copy link

Jo3116 commented Jan 13, 2021

  • Operating System version: macOS Catalina 10.15.6
  • Firebase SDK version: 4.1.0
  • Library version: Unsure Latest i believe
  • Firebase Product: realtime database

###The problem
Cannot connect to a realtime Db hosted in Europe west because of invalid database URL. I was attempting to use a url ending in europe-west1.firebasedatabase.app to connect to a Europe hosting but received the error invalid database URL: want host: "firebaseio.com

Steps to reproduce:

Attempt to create a new client using app.DatabaseWithURL passing in a Europe url ending in europe-west1.firebasedatabase.app

Relevant Code:

func NewFirebaseConnection(ctx context.Context, url string) FirebaseConnection {
	var conn FirebaseConnection
	conn.app = initializeApp(ctx)
	conn.client = initializeClient(ctx, conn.app, url)
	return conn
}

// initializeApp creates a firebase app object
func initializeApp(ctx context.Context) *firebase.App {
	// Initialize the app with a service account, granting admin privileges
	app, err := firebase.NewApp(ctx, nil)
	if err != nil {
		log.Fatalln("Error initializing app:", err)
	}

	return app
}

// initializeClient creates a firebase client object
func initializeClient(ctx context.Context, app *firebase.App, url string) *db.Client {
	client, err := app.DatabaseWithURL(ctx, url)
	if err != nil {
		log.Fatalln("Error initializing database client:", err)
	}

	return client
}
@google-oss-bot
Copy link
Collaborator

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@hiranya911
Copy link
Contributor

This requires a fix similar to firebase/firebase-admin-python#517

@thameezb
Copy link
Contributor

Hitting the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@hiranya911 @thameezb @google-oss-bot @Jo3116 and others