I'm trying to run firebase functions with pubsub locally.
Have configured emulators with firebase init emulators
.
firebase emulators:start --only pubsub
works properly, I can see log:
┌──────────┬────────────────┐
│ Emulator │ Host:Port │
├──────────┼────────────────┤
│ Pub/Sub │ localhost:8085 │
└──────────┴────────────────┘
pubsub emulator config in firebase.json:
"pubsub": {
"host": "localhost",
"port": 8085
},
A pubsub handler function is exported:
exports.testPubsub = functions.pubsub.topic("test-pubsub").onPublish(async (message) => {
console.log(`test event received by pubsub handler: ${message.json}`);
});
I run firebase functions with: firebase serve --only functions
This line appears in console output:
functions[pubsub-testPubsub]: function ignored because the pubsub emulator does not exist or is not running. {"metadata":{"emulator":{"name":"functions"},"message":"function ignored because the pubsub emulator does not exist or is not running."}}
Which means function was found but for some reason firebase cannot connect to pubsub emulator, despite all the configs.
And here is the question: How to test pubsub and firebase functions on local machine?