【问题标题】:Google Endpoints + grpc-web谷歌端点 + grpc-web
【发布时间】:2019-06-09 13:33:07
【问题描述】:

如 Google 端点 (https://github.com/cloudendpoints/esp/pull/283) 的 esp 代理的更改日志中所示,已为其添加了对 grpc-web 的支持。

但是我无法让它工作。我使用以下 cors 配置部署了 esp

# Note: The following lines are included in a server block, so we cannot use all Nginx constructs here.
set $cors_expose_headers "";
set $cors_max_age "";

if ($request_method = 'OPTIONS') {
    set $cors_max_age 1728000;
    return 204;
}

if ($request_method = 'POST') {
    set $cors_expose_headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout';
}

if ($request_method = 'GET') {
    set $cors_expose_headers 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout';
}

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout';
add_header 'Access-Control-Expose-Headers' $cors_expose_headers;
add_header 'Access-Control-Max-Age' $cors_max_age;

然后配置了一个 GRPC Google 端点。

当我尝试向该端点发送 grpc-web 请求时,我可以看到 OPTIONS 请求已通过,但实际请求返回 400 并带有以下响应

{
 "code": 3,
 "message": "Unexpected token.\AAAAASIKAF5etnRlbkFw\n^",
 "details": [
  {
   "@type": "type.googleapis.com/google.rpc.DebugInfo",
   "stackEntries": [],
   "detail": "internal"
  }
 ]
}

我认为这是从 Google Endpoints 中恢复过来的,这导致人们相信 grpc-web 支持可能还没有完全到位。

有没有人设法让这个工作?

【问题讨论】:

    标签: google-cloud-platform google-cloud-endpoints grpc grpc-web


    【解决方案1】:

    事实证明,正如问题中链接的拉取请求上的对话所示(我稍后也测试过),问题是我试图使用谷歌云端点不支持的 grpc-web-text 协议.

    经过一些测试,我可以确认 Google 云端点确实支持 grpc-web,但仅支持二进制有线格式,这意味着不支持服务器流式传输,仅支持一元调用

    【讨论】:

      猜你喜欢
      • 2019-06-08
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      • 2018-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多