Skip to content

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

@Jo3116

Description

@Jo3116
  • 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
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions