从Google端点的esp代理(https://github.com/cloudendpoints/esp/pull/283)的更改日志中可以看到,已经为它添加了对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 Endpoint返回的,这导致人们相信grpc-web支持可能还没有完全实现。
有没有人能让它工作起来?
发布于 2019-01-24 00:23:46
事实证明,正如问题中链接的关于pull请求的对话所显示的(也是我后来测试的),问题是我试图使用Google cloud端点不支持的grpc-web-text协议。
经过一些测试,我可以确认Google云端点确实支持grpc-web,但只支持二进制线格式,这意味着不支持服务器流,只支持一元调用。
https://stackoverflow.com/questions/54200545
复制相似问题