Skip to content

Connecting to Data Connect emulator raises an SSL error #2852

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

Closed
aalej opened this issue Feb 11, 2025 · 1 comment · Fixed by #2853
Closed

Connecting to Data Connect emulator raises an SSL error #2852

aalej opened this issue Feb 11, 2025 · 1 comment · Fixed by #2853

Comments

@aalej
Copy link

aalej commented Feb 11, 2025

[READ] Step 1: Are you in the right place?

  • For issues related to the code in this repository file a Github issue.
  • If the issue pertains to Cloud Firestore, read the instructions in the "Firestore issue"
    template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: 14.7.2
  • Firebase SDK version: Firebase Admin v13.1.0
  • Firebase Product: Data Connect
  • Node.js version: v22.13.1
  • NPM version: v10.9.2

[REQUIRED] Step 3: Describe the problem

While connected to the emulator, trying to perform a query using Data Connect raises an SSL error. The docs mentions using export DATA_CONNECT_EMULATOR_HOST="127.0.0.1:8080" to connect to the emulator.

  1. Looking at https://github.com/firebase/firebase-tools/blob/2bfb61bde9fd5a247f323aad2ebcf567a73666f9/src/emulator/constants.ts#L17, the default port of the Data Connect emulator is 9399, so I think we should be using export DATA_CONNECT_EMULATOR_HOST="127.0.0.1:9399"

  2. Internally, in the Admin SDK, I think we should automatically format the URL to include/start with http:// similar to Auth

Steps to reproduce:

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

MCVE and steps to repro in https://github.com/aalej/firebase-admin-2852

Relevant Code:

import { initializeApp } from "firebase-admin/app";
import { getDataConnect } from 'firebase-admin/data-connect';

// From https://firebase.google.com/docs/data-connect/admin-sdk#use_the_sdk_with_the_emulator but changed 8080 to 9399
process.env.DATA_CONNECT_EMULATOR_HOST = "127.0.0.1:9399"

initializeApp({
    projectId: "demo-project",
    credential: {
        getAccessToken: () => Promise.resolve({ access_token: "fake-access-token", "expires_in": 3600 })
    }
})

const dataConnect = getDataConnect({
    serviceId: "test-dc-2",
    location: "us-central1"
})

async function main() {
    const query = "query ListMovies { movies { id } }";
    const gqlResponse = await dataConnect.executeGraphql(query);
    console.log(JSON.stringify(gqlResponse))
}

main()

Tools Issue: firebase/firebase-tools#8180

@lahirumaramba
Copy link
Member

lahirumaramba commented Feb 13, 2025

Hey @aalej thank you for the repro, I really appreciate it. I have a PR pending to fix this issue. Stay tuned.

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.

2 participants