2015-12-17 110 views
1

我試圖通過使用服務定義在https://github.com/google/googleapis/blob/master/google/pubsub/v1/pubsub.proto使用GRPC和protobuf的(生成的客戶端)在HTTP上2使用谷歌雲PubSub的

使用谷歌的雲計算髮布訂閱服務,我能夠生成客戶端代碼和有下面的代碼獲取一個話題:

 ManagedChannelImpl channelImpl = NettyChannelBuilder 
       .forAddress("pubsub.googleapis.com", 443) 
       .negotiationType(NegotiationType.TLS) 
       .build(); 

     ClientAuthInterceptor interceptor = new ClientAuthInterceptor(
       GoogleCredentials.getApplicationDefault().createScoped(SCOPES), 
       ForkJoinPool.commonPool()); 
     Channel channel = ClientInterceptors.intercept(channelImpl, interceptor); 
     PublisherBlockingClient publisher = newBlockingStub(channel); 
     Topic topicInstance; 
     try { 
      topicInstance = publisher.getTopic(GetTopicRequest.newBuilder().setTopic(topic).build()); 
      if (topicInstance != null) { 
       logger.info("Found existing topic: {}", topicInstance.getName()); 
       return publisher; 
      } 
     } catch (Exception ex) { 
      logger.info("Unable to find topic: {}", topic); 
     } 

這總是失敗與404網絡通信(在調試日誌記錄)似乎確認客戶端擊中了錯誤的端點(對於發佈消息請求):

DEBUG 2015-12-17 00:58:07,962 [grpc-default-worker-ELG-0] i.g.n.NettyClientTransport: 
----------------OUTBOUND-------------------- 
HEADERS: streamId=5, headers=DefaultHttp2Headers[:authority: pubsub.googleapis.com:443, :path: /google.pubsub.v1.Publisher/Publish, :method: POST, :scheme: https, authorization: Bearer ya29.TQIWiptEf4KsAKObPIaLaJRcq49SQ2vAutO4eIC-kgM4XwvX9p-9sFBR4eNfzE_yLiBs1A, content-type: application/grpc, te: trailers, user-agent: grpc-java-netty/0.9.0], streamDependency=0, weight=16, exclusive=false, padding=0, endStream=false 
------------------------------------ 
DEBUG 2015-12-17 00:58:07,975 [grpc-default-worker-ELG-0] i.g.n.NettyClientTransport: 
----------------OUTBOUND-------------------- 
DATA: streamId=5, padding=0, endStream=true, length=725, bytes=00000002d00a136465765f616368617568616e2d6576656e747312b8050af9047b22486f7374223a226c6f63616c686f73743a3434303830222c22436f6e6e65... 
------------------------------------ 
DEBUG 2015-12-17 00:58:11,492 [grpc-default-worker-ELG-0] i.g.n.NettyClientTransport: 
----------------INBOUND-------------------- 
HEADERS: streamId=5, headers=DefaultHttp2Headers[:status: 404, date: Thu, 17 Dec 2015 08:58:08 GMT, content-type: text/html; charset=UTF-8, server: ESF, content-length: 1595, x-xss-protection: 1; mode=block, x-frame-options: SAMEORIGIN, x-content-type-options: nosniff, alternate-protocol: 443:quic,p=1, alt-svc: quic=":443"; ma=604800; v="30,29,28,27,26,25"], padding=0, endStream=false 
------------------------------------ 
DEBUG 2015-12-17 00:58:26,357 [grpc-default-worker-ELG-0] i.g.n.NettyClientTransport: 
----------------INBOUND-------------------- 
DATA: streamId=5, padding=0, endStream=true, length=1595, bytes=3c21444f43545950452068746d6c3e0a3c68746d6c206c616e673d656e3e0a20203c6d65746120636861727365743d7574662d383e0a20203c6d657461206e61... 
------------------------------------ 
DEBUG 2015-12-17 00:58:26,357 [grpc-default-worker-ELG-0] i.g.n.NettyClientTransport: 
----------------INBOUND-------------------- 
PING: ack=false, length=8, bytes=0000000000000002 
------------------------------------ 
DEBUG 2015-12-17 00:58:26,358 [grpc-default-worker-ELG-0] i.g.n.NettyClientTransport: 
----------------OUTBOUND-------------------- 
PING: ack=true, length=8, bytes=00000000000000 

我在這裏做錯了什麼?是否支持HTTP 2(使用protobuf)的pubsub?

回答

2

截至2015年12月17日,我們尚未在pubsub.googleapis.com端點上啓用gRPC。現在我們正在積極測試gRPC支持,希望我們可以在不久的將來提供。

+0

這仍然有效嗎?我在https://github.com/GoogleCloudPlatform/cloud-pubsub-samples-java/tree/master/grpc上看到了一些grpc樣本,並在想這是否可能。 –

相關問題