gpt4 book ai didi

google-cloud-platform - 谷歌端点 + grpc-web

转载 作者:行者123 更新时间:2023-12-04 02:52:54 24 4
gpt4 key购买 nike

如 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 Endpoints 返回的结果,这导致人们相信 grpc-web 支持可能还不完全存在。

有没有人设法让它工作?

最佳答案

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

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

关于google-cloud-platform - 谷歌端点 + grpc-web,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54200545/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com