Skip to content

Connecting to Data Connect emulator raises an SSL error #2852

@aalej

Description

@aalej

[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

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions