Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform GCloud pubsub模拟器不';“不尊重”;PUBSUB“仿真器”主机;环境变量_Google Cloud Platform_Google Cloud Pubsub_Gcloud Node - Fatal编程技术网

Google cloud platform GCloud pubsub模拟器不';“不尊重”;PUBSUB“仿真器”主机;环境变量

Google cloud platform GCloud pubsub模拟器不';“不尊重”;PUBSUB“仿真器”主机;环境变量,google-cloud-platform,google-cloud-pubsub,gcloud-node,Google Cloud Platform,Google Cloud Pubsub,Gcloud Node,我尝试在本地运行pubsub模拟器,并使用我在pubsub上运行的现有服务向它发送消息。没有收到消息,我得到的只是日志中的身份验证错误 [pubsub] Jan 22, 2017 3:43:16 PM com.google.cloud.iam.testing.v1.shared.authorization.AuthInterceptor interceptCall [pubsub] INFO: Authentication interceptor: Header value is null [p

我尝试在本地运行pubsub模拟器,并使用我在pubsub上运行的现有服务向它发送消息。没有收到消息,我得到的只是日志中的身份验证错误

[pubsub] Jan 22, 2017 3:43:16 PM com.google.cloud.iam.testing.v1.shared.authorization.AuthInterceptor interceptCall
[pubsub] INFO: Authentication interceptor: Header value is null
[pubsub] Jan 22, 2017 3:43:16 PM com.google.cloud.iam.testing.v1.shared.authorization.AuthInterceptor interceptCall
[pubsub] INFO: Authentication interceptor: invalid or missing token
我正在请求从dotnet和nodejs发布和拉取

C#

NodeJs


我偶然遇到了这个问题

在研究它的过程中,我发现了以下帖子:“没有任何问题。当使用模拟器时,我们没有传递任何凭据,这是日志告诉您的,任何请求都没有提供身份验证头。”


我的消息在搜索主题时开始发布,所以可能只是延迟了一段时间。

标题值null是一个红色的harring。看起来dotnetsdk不像nodejs sdk那样尊重环境变量。我与jskeet通信,他创建了一个问题,添加了说明如何启用emulator的文档:

下面是我如何用C创建PublisherClient的#

private static PublisherClient CreatePublisherClient(){
var emulatorHostAndPort=Environment.GetEnvironmentVariable(“PUBSUB_EMULATOR_HOST”);
if(String.IsNullOrWhiteSpace(emulatorHostAndPort)){
返回PublisherClient.Create();
}否则{
var通道=新通道(模拟器主机端口,通道凭证。不安全);
返回PublisherClient.Create(频道);
}
}
var creds = GoogleCredential.GetApplicationDefaultAsync().Result;
if (creds.IsCreateScopedRequired) {
    creds = creds.CreateScoped(new [] { PubsubService.Scope.Pubsub } );
}

return new PubsubService(
    new BaseClientService.Initializer() {
        HttpClientInitializer = creds,
        ApplicationName = "My Wonderful App"
    }
);
var pubsub = require('@google-cloud/pubsub');

var pubsubClient = pubsub({
  projectId: config.get('GCLOUD_PROJECT')
});