I'm having an issue with the PubSub module for Node.js. I've created a local environment using Docker and the PubSub emulator. I'm able to publish a message and retrieve it using the asynchronous pull (as documented here: https://cloud.google.com/pubsub/docs/pull#asynchronous-pull). However when I'm trying to use the synchronous pull (https://cloud.google.com/pubsub/docs/pull#synchronous-pull) I keep having the following error:
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. at GoogleAuth. (/var/code/node_modules/google-auth-library/build/src/auth/googleauth.js:167:23) at next (native) at fulfilled (/var/code/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58) at process._tickCallback (internal/process/next_tick.js:109:7) (node:493) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 32)
This error happens whenever I'm trying to instantiate the v1 PublisherClient or SubscriberClient:
const pubsub = require('@google-cloud/pubsub');
new pubsub.v1.PublisherClient();
new pubsub.v1.SubscriberClient();
I feel like the v1 components do not work with the emulator but connect directly to the cloud services instead. Is there a way to make these clients connect to the emulator rather than the cloud? I can't find any... Thanks !