pubsub.NewClient 卡在开发机器和 docker 中
Posted
技术标签:
【中文标题】pubsub.NewClient 卡在开发机器和 docker 中【英文标题】:pubsub.NewClient is stuck in development machine as well as in docker 【发布时间】:2020-04-01 02:12:35 【问题描述】:我明白了,已经有人问过类似的问题here
但是建议的解决方案对我不起作用。
下面是我的代码sn-p
ctx := context.Background()
client, err := pubsub.NewClient(ctx, projectID)
if err != nil
return fmt.Errorf("pubsub.NewClient: %v", err)
fmt.Printf("pubsub newclient called")
defer client.Close()
但是它卡在 NewClient 调用中,甚至没有返回任何错误。
将 GRPC_GO_LOG_SEVERITY_LEVEL 设置为 info 会显示以下信息。
INFO: 2019/12/07 07:46:14 parsed scheme: ""
INFO: 2019/12/07 07:46:14 scheme "" not registered, fallback to default scheme
INFO: 2019/12/07 07:46:14 ccResolverWrapper: sending update to cc: [pubsub.googleapis.com:443 0 <nil>]
INFO: 2019/12/07 07:46:14 balancerWrapper: got update addr from Notify: [pubsub.googleapis.com:443 0 pubsub.googleapis.com:443 1 pubsub.googleapis.com:443 2 pubsub.googleapis.com:443 3]
我在 ubuntu 16.04 中运行这个程序,它包含正确的 ssl 证书。
同样的代码也不能在 docker 中运行。 下面是我的 docker 文件。
FROM golang:1.12 as builder
RUN mkdir /app
ADD main.go /app/
COPY go.mod go.sum /app/
WORKDIR /app
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/main .
RUN ls -l
CMD ["./main"]
有人可以建议如何调试这个问题吗?
【问题讨论】:
【参考方案1】:您是否有任何代理设置或其他可能阻止拨打 Google 的东西?可能与此https://github.com/googleapis/google-cloud-go/issues/1202
有关【讨论】:
以上是关于pubsub.NewClient 卡在开发机器和 docker 中的主要内容,如果未能解决你的问题,请参考以下文章
带有 youtube dl 的不和谐机器人音乐不会卡在网页下载中