调用Apigee代理访问Google Cloud Function时出现上游请求超时问题
解决Apigee代理调用Google Cloud Function超时问题
问题原因
你遇到的30秒"upstream request timeout"错误,核心是Apigee默认的目标读取超时时间为30秒,而你的Cloud Function需要40秒才能返回响应。之前配置中使用的io.timeout.millis并非控制目标响应等待的正确属性,导致修改未生效。
正确配置方案
在TargetEndpoint的HTTPTargetConnection下添加read.timeout.millis属性,设置为大于40秒的数值(比如60000毫秒,即1分钟),同时可按需保留连接超时配置。示例配置如下:
<TargetEndpoint name="default"> <HTTPTargetConnection> <URL>你的Google Cloud Function实际URL</URL> <Properties> <!-- 连接超时:建立TCP连接的超时时间,默认5秒,可按需调整 --> <Property name="connect.timeout.millis">5000</Property> <!-- 读取超时:等待目标服务返回响应的最大时间,设置为大于40秒的值 --> <Property name="read.timeout.millis">60000</Property> </Properties> </HTTPTargetConnection> </TargetEndpoint>
关键注意事项
- 修改配置后必须重新部署代理到目标环境,新配置才会生效。
- 确认你的Google Cloud Function自身超时设置不小于40秒(Cloud Function默认超时为90秒,通常无需调整)。
- 若使用Apigee X,目标端点的超时设置会覆盖默认值,无需额外环境级配置。
内容的提问来源于stack exchange,提问作者C. Oezer
相关产品推荐
相关产品推荐

