本文介绍了gloud的Java。 PERMISSION_DENIED:Google云端发布/ Sub API(实验)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用gloud-java实验库。今天更新后,发生错误。
从本地库运行示例(此错误自动显示在谷歌云灵活引擎中,尽管部署不会在一周内完成) public class PullTest {
private static final transient Logger logger = Logger.getLogger(MethodHandles.lookup()。lookupClass()。getName());
$ b $ public static void main(String ... args)throws Exception {
try(PubSub pubsub = PubSubOptions.defaultInstance()。service()){
String subscriptionName =订阅段;
订阅订阅= pubsub.getSubscription(subscriptionName);
}
}
}
抛出异常
2016年8月10日上午2:19:08 io.grpc.internal.ManagedChannelImpl< init>
INFO:[ManagedChannelImpl @ 131ef10] Created with target pubsub-experimental.googleapis.com:443
Aug 10,2016 2:19:08 AM io.grpc.internal.ManagedChannelImpl< init>
INFO:[ManagedChannelImpl @ 394df057]用目标创建pubsub-experimental.googleapis.com:443
2016年8月10日上午2:19:10 io.grpc.internal.ManagedChannelImpl maybeTerminateChannel
INFO :[ManagedChannelImpl @ 131ef10]终止
线程main中的异常com.google.cloud.pubsub.PubSubException:io.grpc.StatusRuntimeException:PERMISSION_DENIED:Google云端Pub / Sub API(实验性)尚未用于项目google.com:cloudsdktool之前或禁用。访问https://console.developers.google.com/apis/api/pubsub-experimental.googleapis.com/overview?project=google.com:cloudsdktool启用它,然后重试。如果您最近启用了此API,请等待几分钟,以便将操作传播到我们的系统并重试。
at com.google.cloud.pubsub.spi.DefaultPubSubRpc $ 1.apply(DefaultPubSubRpc.java:183)
at com.google.cloud.pubsub.spi.DefaultPubSubRpc $ 1.apply(DefaultPubSubRpc.java: 177)
在com.google.common.util.concurrent.Futures $ CatchingFuture.doFallback(Futures.java:842)
在com.google.common.util.concurrent.Futures $ CatchingFuture.doFallback( Futures.java:834)
,位于com.google.common.util.concurrent.Futures $ AbstractCatchingFuture.run(Futures.java:789)
,位于com.google.common.util.concurrent.MoreExecutors $ DirectExecutor.execute(MoreExecutors.java:456)
,com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:817)
,com.google.common.util.concurrent。 AbstractFuture.complete(AbstractFuture.java:753)
位于com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:634)
位于com.google.common.util.concurrent。 SettableFuture.setException(SettableFuture.java:53)
at com.google.api.gax.grpc.RetryingCallable $ Retryer $ 1.o nFailure(RetryingCallable.java:139)
在com.google.common.util.concurrent.Futures $ 6.run(Futures.java:1764)
在com.google.common.util.concurrent.MoreExecutors $ DirectExecutor.execute(MoreExecutors.java:456)
com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:817)
com.google.common.util.concurrent .AbstractFuture.complete(AbstractFuture.java:753)com.google.common.util.concurrent.AbstractFuture.setException中的
(AbstractFuture.java:634)com.google.common.util.concurrent中的
.SettableFuture.setException(SettableFuture.java:53)
at com.google.com.api.gax.grpc.ExceptionTransformingCallable $ 1.onFailure(ExceptionTransformingCallable.java:90)
com.google.common.util。 concurrent.Futures $ 6.run(Futures.java:1764)
com.google.common.util.concurrent.MoreExecutors $ DirectExecutor.execute(MoreExecutors.java:456)
com.google.common .util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:817)
,com.google。 common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:753)
,位于com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:634)
位于io.grpc。 stub.ClientCalls $ GrpcFuture.setException(ClientCalls.java:331)
at io.grpc.stub.ClientCalls $ UnaryStreamToFuture.onClose(ClientCalls.java:307)
at io.grpc.internal.ClientCallImpl $ ClientStreamListenerImpl $ 3.runInContext(ClientCallImpl.java:462)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:54)
at io.grpc.internal.SerializingExecutor $ TaskRunner.run(SerializingExecutor .java:154)
at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 201(ScheduledThreadPoolExecutor.java:180)$ b $在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
在java.uti l.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)$ java.util.concurrent.ThreadPoolExecutor
$ Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run( Thread.java:745)
导致:com.google.api.gax.grpc.ApiException:io.grpc.StatusRuntimeException:PERMISSION_DENIED:谷歌云Pub / Sub API(实验)尚未在项目谷歌中使用。 com:cloudsdktool之前或禁用。访问https://console.developers.google.com/apis/api/pubsub-experimental.googleapis.com/overview?project=google.com:cloudsdktool启用它,然后重试。如果您最近启用了此API,请等待几分钟,以便将操作传播到我们的系统并重试。
... 18更多
导致:io.grpc.StatusRuntimeException:PERMISSION_DENIED:谷歌云Pub / Sub API(实验)在项目google.com:cloudsdktool之前还没有被使用,或者被禁用。访问https://console.developers.google.com/apis/api/pubsub-experimental.googleapis.com/overview?project=google.com:cloudsdktool启用它,然后重试。如果您最近启用了此API,请等待几分钟,以便将操作传播到我们的系统并重试。
at io.grpc.Status.asRuntimeException(Status.java:503)
... 11 more
2016年8月10日上午2:19:10 io.grpc.internal.ManagedChannelImpl maybeTerminateChannel
INFO:[ManagedChannelImpl @ 394df057]已终止
如何解决此问题?
问题从无到有。在早上它工作:)
ps
$ gcloud信息
显示正确的信息
$ gcloud auth login
没有帮助
解决方案
但我不知道任何Java特定的细节。)
如果您只是想使用PubSub v1 API,我认为问题在于它连接到 pubsub-experimental.googleapis.com
而不是 pubsub.googleapis.com
。我不确定为什么它将其视为默认端点 - 看起来不错 - 但我相信你应该可以通过手动设置主机来修复它:
PubSubOptions options = PubSubOptions.builder()。host(pubsub.googleapis.com)。build();
try(PubSub pubsub = options.service()){
String subscriptionName =subscription-segment;
订阅订阅= pubsub.getSubscription(subscriptionName);
}
鉴于github中的源代码似乎没问题,您可能还想检查您正在使用该库的最新发布版本......可能是因为默认主机已经修复。根据评论,gcloud-java 0.2.7默认使用正确的主机。
I use gloud-java experimental library. After update today, error occurred.Run example from library local (This error is automatically appeared in the google cloud flexible engine, although deploy not produced for a week)
public class PullTest {
private static final transient Logger logger = Logger.getLogger(MethodHandles.lookup().lookupClass().getName());
public static void main(String... args) throws Exception {
try (PubSub pubsub = PubSubOptions.defaultInstance().service()) {
String subscriptionName = "subscription-segment";
Subscription subscription = pubsub.getSubscription(subscriptionName);
}
}
}
throw exception
Aug 10, 2016 2:19:08 AM io.grpc.internal.ManagedChannelImpl <init>
INFO: [ManagedChannelImpl@131ef10] Created with target pubsub-experimental.googleapis.com:443
Aug 10, 2016 2:19:08 AM io.grpc.internal.ManagedChannelImpl <init>
INFO: [ManagedChannelImpl@394df057] Created with target pubsub-experimental.googleapis.com:443
Aug 10, 2016 2:19:10 AM io.grpc.internal.ManagedChannelImpl maybeTerminateChannel
INFO: [ManagedChannelImpl@131ef10] Terminated
Exception in thread "main" com.google.cloud.pubsub.PubSubException: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Google Cloud Pub/Sub API (Experimental) has not been used in project google.com:cloudsdktool before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/pubsub-experimental.googleapis.com/overview?project=google.com:cloudsdktool then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
at com.google.cloud.pubsub.spi.DefaultPubSubRpc$1.apply(DefaultPubSubRpc.java:183)
at com.google.cloud.pubsub.spi.DefaultPubSubRpc$1.apply(DefaultPubSubRpc.java:177)
at com.google.common.util.concurrent.Futures$CatchingFuture.doFallback(Futures.java:842)
at com.google.common.util.concurrent.Futures$CatchingFuture.doFallback(Futures.java:834)
at com.google.common.util.concurrent.Futures$AbstractCatchingFuture.run(Futures.java:789)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:456)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:817)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:753)
at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:634)
at com.google.common.util.concurrent.SettableFuture.setException(SettableFuture.java:53)
at com.google.api.gax.grpc.RetryingCallable$Retryer$1.onFailure(RetryingCallable.java:139)
at com.google.common.util.concurrent.Futures$6.run(Futures.java:1764)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:456)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:817)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:753)
at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:634)
at com.google.common.util.concurrent.SettableFuture.setException(SettableFuture.java:53)
at com.google.api.gax.grpc.ExceptionTransformingCallable$1.onFailure(ExceptionTransformingCallable.java:90)
at com.google.common.util.concurrent.Futures$6.run(Futures.java:1764)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:456)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:817)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:753)
at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:634)
at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:331)
at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:307)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$3.runInContext(ClientCallImpl.java:462)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:54)
at io.grpc.internal.SerializingExecutor$TaskRunner.run(SerializingExecutor.java:154)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.google.api.gax.grpc.ApiException: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Google Cloud Pub/Sub API (Experimental) has not been used in project google.com:cloudsdktool before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/pubsub-experimental.googleapis.com/overview?project=google.com:cloudsdktool then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
... 18 more
Caused by: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Google Cloud Pub/Sub API (Experimental) has not been used in project google.com:cloudsdktool before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/pubsub-experimental.googleapis.com/overview?project=google.com:cloudsdktool then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
at io.grpc.Status.asRuntimeException(Status.java:503)
... 11 more
Aug 10, 2016 2:19:10 AM io.grpc.internal.ManagedChannelImpl maybeTerminateChannel
INFO: [ManagedChannelImpl@394df057] Terminated
How to get around this problem?The problem arose out of nothing. In the morning it worked :)
p.s.
$ gcloud info
shows the correct information
$ gcloud auth login
did not help
解决方案
(Caveat: I work on the team building the equivalent library for .NET. That means I know a certain amount of the infrastructure involved, but I don't know any Java-specific details.)
If you're just trying to use the PubSub v1 API, I believe the problem is that it's connecting to pubsub-experimental.googleapis.com
instead of pubsub.googleapis.com
. I'm not sure why it's treating that as the default endpoint - the default host in the code look okay - but I believe you should be able to fix it by setting the host manually:
PubSubOptions options = PubSubOptions.builder().host("pubsub.googleapis.com").build();
try (PubSub pubsub = options.service()) {
String subscriptionName = "subscription-segment";
Subscription subscription = pubsub.getSubscription(subscriptionName);
}
Given that the source code in github seems okay, you might also want to check that you're using the latest published version of the library... it may well be that the default host has been fixed in that. As per comments, gcloud-java 0.2.7 uses the correct host by default.
这篇关于gloud的Java。 PERMISSION_DENIED:Google云端发布/ Sub API(实验)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-15 01:45