Reputation: 649
I tried running the pubsub emulator locally and send messages to it with existing services that I have running on pubsub. Messages weren't received, and all I get are auth errors in the logs.
[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
I'm making requests to publish and pull from both dotnet and nodejs.
C#
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"
}
);
NodeJs
var pubsub = require('@google-cloud/pubsub');
var pubsubClient = pubsub({
projectId: config.get('GCLOUD_PROJECT')
});
Upvotes: 1
Views: 3187
Reputation: 649
The header value null was a red harring. It looks like the dotnet sdk doesn't respect the environment variable like the nodejs sdk does. I corresponded with jskeet and he created an issue to add the documentation for showing how to enable the use of the emulator: https://github.com/GoogleCloudPlatform/google-cloud-dotnet/issues/859
Here's how I created the PublisherClient in C#
private static PublisherClient CreatePublisherClient() {
var emulatorHostAndPort = Environment.GetEnvironmentVariable("PUBSUB_EMULATOR_HOST");
if (String.IsNullOrWhiteSpace(emulatorHostAndPort)) {
return PublisherClient.Create();
} else {
var channel = new Channel(emulatorHostAndPort, ChannelCredentials.Insecure);
return PublisherClient.Create(channel);
}
}
Upvotes: 0
Reputation: 11
I ran in to this problem.
While researching it, I found the following post: "Nothing is going wrong. When using the emulator we pass no credentials and this is what the logs are telling you, that no authentication header was provided with any of the requests." - https://www.bountysource.com/issues/39093553-pubsub-emulator-authinterceptor-question
My messages started publishing while researching the topic, so it's probably just a delay.
Upvotes: 1