简体   繁体   中英

Method not found: google.pubsub.v1.Publisher/CreateTopic

I'm trying to publish messages to pubsub from a next.js app.

I'm working through these instructions to setup the node client and run it against the pubsub emulator, but I'm getting the following error for all methods I try:

Error: 12 UNIMPLEMENTED: Method not found: google.pubsub.v1.Publisher/GetTopic
    at Object.callErrorFromStatus (/Users/ethan/Documents/code/refold-library/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus (/Users/ethan/Documents/code/refold-library/node_modules/@grpc/grpc-js/build/src/client.js:190:52)
    at Object.onReceiveStatus (/Users/ethan/Documents/code/refold-library/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:365:141)
    at Object.onReceiveStatus (/Users/ethan/Documents/code/refold-library/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:328:181)
    at /Users/ethan/Documents/code/refold-library/node_modules/@grpc/grpc-js/build/src/call-stream.js:188:78
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
for call at
    at ServiceClientImpl.makeUnaryRequest (/Users/ethan/Documents/code/refold-library/node_modules/@grpc/grpc-js/build/src/client.js:160:30)
    at ServiceClientImpl.<anonymous> (/Users/ethan/Documents/code/refold-library/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at /Users/ethan/Documents/code/refold-library/node_modules/@google-cloud/pubsub/build/src/v1/publisher_client.js:214:29
    at /Users/ethan/Documents/code/refold-library/node_modules/google-gax/build/src/normalCalls/timeout.js:44:16
    at repeat (/Users/ethan/Documents/code/refold-library/node_modules/google-gax/build/src/normalCalls/retries.js:80:25)
    at /Users/ethan/Documents/code/refold-library/node_modules/google-gax/build/src/normalCalls/retries.js:118:13
    at OngoingCall.call (/Users/ethan/Documents/code/refold-library/node_modules/google-gax/build/src/call.js:67:27)
    at NormalApiCaller.call (/Users/ethan/Documents/code/refold-library/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js:34:19)
    at /Users/ethan/Documents/code/refold-library/node_modules/google-gax/build/src/createApiCall.js:84:30 {
  code: 12,
  details: 'Method not found: google.pubsub.v1.Publisher/GetTopic',
  metadata: Metadata {
    internalRepr: Map(1) { 'content-type' => [Array] },
    options: {}
  },
  note: 'Exception occurred in retry method that was not classified as transient'
}

My Code:

import { PubSub } from '@google-cloud/pubsub'

export const getContentCollectorPipeline = async () => {
  console.info('Initializing Pubsub')
  const pubsub = new PubSub()

  console.info('Initializing topic')
  const topic = pubsub.topic('topic')

  console.info('Checking topic exists')
  const exists = await topic.exists()

  if (!exists) {
    return null
  }

  return topic
}

Note: I'm using the firebase emulators rather than the standalone Pub/Sub emulator.

I haven't been able to find much for this error on google, so I'm guessing I did something stupid.

Any ideas?

Nevermind. I fatfingered the pubsub port in my environment. Kind of a strange error message for not being able to connect to the emulator.

TLDR: check your ports are correct.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM