<ph type="x-smartling-placeholder"></ph>
您正在查看 Apigee Edge 文档。
转到
Apigee X 文档。 信息
问题
客户端应用收到 HTTP 状态代码 400 Bad Request 和错误代码
messaging.adaptors.http.flow.DecompressionFailureAtRequest 作为对 API 的响应
调用。
错误消息
客户端应用将获得以下响应代码:
HTTP/1.1 400 Bad Request
此外,您可能还会看到类似于如下所示的错误消息:
{
"fault":{
"faultstring":"Decompression failure at request",
"detail":{
"errorcode":"messaging.adaptors.http.flow.DecompressionFailureAtRequest"
}
}
}可能的原因
只有在以下情况下,才会发生此错误:
- HTTP 请求标头
Content-Encoding中指定的编码 有效且 由 Apigee Edge 提供支持, - 客户端在 HTTP 请求中发送的载荷格式不会
匹配
Content-Encoding标头中指定的编码格式
但是
这是因为 Apigee Edge 无法使用指定编码解码载荷,因为
与
Content-Encoding 标头。
下面列举了一些受支持的 Content-Encoding值示例,以及 Apigee Edge 如何
在以下情况下,载荷格式应为:
| 场景 | Content-Encoding | 预期的载荷格式 |
|---|---|---|
| 单一编码 | gzip | Unix 请参阅 <ph type="x-smartling-placeholder"></ph> RFC1952 GZIP 格式。 |
| 单一编码 | 缩小 | 此格式使用 请参阅
RFC1950 和
<ph type="x-smartling-placeholder"></ph>
RFC1951 |
| 多重编码 | 多重编码 例如,如果编码进行了两次,则可能是:
|
按标头中显示的指定顺序对载荷应用多种编码。 |
导致此错误的可能原因如下:
| 原因 | 说明 | 适用的问题排查说明 |
|---|---|---|
| <ph type="x-smartling-placeholder"></ph> 请求载荷格式与 Content-Encoding 标头中指定的编码不匹配 | 客户端发送的请求载荷的格式未编码或未编码
与 Content-Encoding 标头中指定的编码匹配。 |
Edge 公有云和私有云用户 |
常见诊断步骤
使用以下工具/技术之一来诊断此错误:
API 监控
<ph type="x-smartling-placeholder">如需使用 API Monitoring 诊断错误,请执行以下操作:
- <ph type="x-smartling-placeholder"></ph> 以拥有的用户身份登录 Apigee Edge 界面 适当的角色。
切换到您要在其中调查问题的单位。
- 导航至分析 >API 监控 >调查页面。
- 选择您观察到错误的具体时间范围。
- 确保将代理过滤器设置为全部。
- 根据时间绘制错误代码。
选择错误代码为
messaging.adaptors.http.flow.DecompressionFailureAtRequest的单元格 如下所示:( 查看大图)
有关错误代码的信息
messaging.adaptors.http.flow.DecompressionFailureAtRequest如下所示:( 查看大图)
点击查看日志,然后展开显示
400错误的行。( 查看大图)
- 在日志窗口中,请注意以下详细信息:
<ph type="x-smartling-placeholder">
- </ph>
- 状态代码:
400 - 故障来源:
proxy - 错误代码:
messaging.adaptors.http.flow.DecompressionFailureAtRequest。
- 状态代码:
- 如果错误来源的值为
proxy,则表示 请求载荷格式与Content-Encoding标头中指定的受支持编码。
跟踪工具
<ph type="x-smartling-placeholder">如需使用跟踪工具诊断错误,请执行以下操作:
- 启用跟踪会话
以及:
<ph type="x-smartling-placeholder">
- </ph>
- 等待发生
400 Bad Request错误,或者 - 如果您可以重现问题,请进行 API 调用并重现问题
400 Bad Request。
- 等待发生
确保已启用 Show all FlowInfos:
- 选择其中一个失败请求并检查跟踪记录。
- 浏览跟踪记录的不同阶段并找到失败之处 错误。
通常,您会在流程中的 Request Received from Client 阶段,如下所示:
( 查看大图)
-
请记下跟踪记录中的属性值:
- 错误:
Decompression failure at request - error.class:
com.apigee.rest.framework.BadRequestException - error.cause::
Not in GZIP format
error.cause 指出请求载荷未采用 GZIP 格式。 这意味着 Apigee Edge 希望请求载荷采用 GZIP 格式
Content-Encoding标头中指定的名称。 - 错误:
确定请求标头
Content-Encoding的值。 为此,请转到 Request Received(从客户端收到请求),如下所示:( 查看大图)
请注意,请求标头
Content-Encoding的值确实是gzip。上面的跟踪示例显示了请求标头中指定的编码
Content-Encoding为gzip;但请求载荷 未采用 GZIP 格式。因此,Apigee 无法使用 gzip 并返回错误Decompression failure at request。- 按以下步骤查看 Apigee Edge 返回的状态代码和错误消息:
添加到跟踪记录中的 Response Sent to Client 阶段,如下所示:
( 查看大图)
请注意跟踪记录的以下详细信息:
- 状态代码:
400 Bad Request。 - 错误内容:
{"fault":{"faultstring":"Decompression failure at request","detail":{"errorcode":"messaging.adaptors.http.flow.DecompressionFailureAtRequest"}}}
- 状态代码:
进入跟踪记录中的 AX(记录的 Google Analytics 数据)阶段 然后点击它
- 向下滚动到阶段详情、错误标头部分,然后
确定 X-Apigee-fault-code 和 X-Apigee-fault-source 的值
如下所示:
( 查看大图)
- 您将看到 X-Apigee-fault-code 和 X-Apigee-fault-source 的值
以
messaging.adaptors.http.flow.DecompressionFailureAtRequest和policy,这表示请求载荷格式与Content-Encoding标头中指定的任何一种编码。响应标头 值 X-Apigee-fault-code messaging.adaptors.http.flow.DecompressionFailureAtRequestX-Apigee-fault-source policy
NGINX
<ph type="x-smartling-placeholder">如需使用 NGINX 访问日志诊断错误,请执行以下操作:
- 如果您是 Private Cloud 用户,则可以使用 NGINX 访问日志
确定有关 HTTP
400错误的关键信息。 查看 NGINX 访问日志:
/opt/apigee/var/log/edge-router/nginx/ORG~ENV.PORT#_access_log其中:ORG、ENV 和 PORT# 替换为实际值。
- 搜索以查看在特定时间段内是否存在任何
400错误 (如果问题在过去发生过)或者是否还有任何请求仍失败,400。 如果您确实在 X-Apigee-fault-code 中找到了任何
400错误 与messaging.adaptors.http.flow.DecompressionFailureAtRequest的值匹配, 然后确定 X-Apigee-fault-source.NGINX 访问日志中的 400 错误示例:
以上 NGINX 访问日志中的示例条目包含以下值: X-Apigee-fault-code 和 X-Apigee-fault-code
响应标头 值 X-Apigee-fault-code messaging.adaptors.http.flow.DecompressionFailureAtRequestX-Apigee-fault-source policy
原因:请求负载的格式与指定的编码不匹配 在 Content-Encoding 标头中
默认情况下,如果有请求标头,Apigee Edge 始终会对载荷进行解压缩
Content-Encoding 包含有效的和
<ph type="x-smartling-placeholder"></ph>
支持的编码。因此,请求载荷的格式应该
应匹配在请求标头 Content-Encoding 中指定的编码。
如果存在不匹配,就会收到此错误。
诊断
- 确定使用 API 观察到的错误的错误代码和错误来源 监控、跟踪工具或 NGINX 访问日志,如 常见的诊断步骤。
- 如果错误代码是
messaging.adaptors.http.flow.DecompressionFailureAtRequest和 故障来源的值为policy或proxy,则此 表示客户端应用发送的请求包含的负载 请求标头Content-Encoding中指定的受支持编码。 您可以使用以下任一方法在 HTTP 请求中确定不匹配问题 方法:
错误消息
如需使用错误消息进行验证,请执行以下操作:
-
如果您有权查看从 Apigee Edge 收到的完整错误消息,则: 请参阅
faultstring。示例错误消息:
"faultstring":"Decompression failure at request"
- 在上述错误消息中,
"Decompression failure at request",这意味着请求 使用Content-Encoding标头。
Trace
如需使用 Trace 进行验证,请执行以下操作:
- 确定请求标头 Content-Encoding 的值 属性 error.cause(使用 Trace) 如常见诊断步骤中所述。
示例跟踪记录中的值如下所示:
- Content-Encoding:
gzip - error.cause::
Not in GZIP format
请求标头 Content-Encoding 的值为 gzip; 但是,请求负载并非采用 GZIP 格式 (以 error.cause 表示)。因此,Apigee Edge 会以
400 Bad Request和错误代码messaging.adaptors.http.flow.DecompressionFailureAtRequest。- Content-Encoding:
实际请求
如需使用实际请求进行验证,请执行以下操作:
如果您有权访问客户端发出的实际请求 然后执行以下步骤:
- 确定传递到请求标头
Content-Encoding的值。 - 确定随请求一起发送的载荷格式。
如果
Content-Encoding标头的值在 <ph type="x-smartling-placeholder"></ph> 支持的编码,但请求负载的格式 与Content-Encoding标头中指定的编码匹配, 那么这就是出现问题的原因示例请求:
curl -v "http://HOSTALIAS/v1/testgzip"
-H "Content-Encoding: gzip"-X POST -d @request_payload.zip上面的示例请求会将值
gzip发送到Content-Encoding标头, <ph type="x-smartling-placeholder"></ph> 支持的编码。但是,请求载荷request_payload.zip采用 ZIP 格式。因此,该要求 失败,并显示400 Bad Request状态代码和错误代码:messaging.adaptors.http.flow.DecompressionFailureAtRequest。
消息处理器日志
<ph type="x-smartling-placeholder">如需使用消息处理器日志进行验证,请执行以下操作:
如果您是 Private Cloud 用户,可以使用消息处理器日志 以确定有关 HTTP
400错误的关键信息。- 使用 API 监控、跟踪工具、 或 NGINX 访问日志(如常见诊断步骤中所述)。
在消息处理器日志中搜索消息 ID:
/opt/apigee/var/log/edge-message-processor/logs/system.log您会看到以下例外情况之一:
情景 #1
场景 1:当 API 请求包含 Content-Encoding: gzip 标头时
2021-07-28 10:21:16,861 NIOThread@0 ERROR HTTP.SERVER - HTTPServer$Context.onInputException() : Message id:rt-57-1 SSLClientChannel[Accepted: Remote:192.168.199.8:8443 Local:192.168.80.234:44284]@28469 useCount=1 bytesRead=0 bytesWritten=28764 age=2739893ms lastIO=0ms isOpen=true.onExceptionRead exception: {} java.util.zip.ZipException: Not in GZIP format 2021-07-28 10:21:16,862 NIOThread@0 ERROR ADAPTORS.HTTP.FLOW - AbstractRequestListener.onException() : Request:POST, uri:/test, message Id:rt-57-1, exception:java.util.zip.ZipException: Not in GZIP format, context:Context@71ea5ac input=ClientInputChannel(SSLClientChannel[Accepted: Remote:192.168.199.8:8443 Local:192.168.80.234:44284]@28469 useCount=1 bytesRead=0 bytesWritten=28764 age=2739894ms lastIO=0ms isOpen=true) 2021-07-28 10:21:16,862 NIOThread@0 INFO HTTP.SERVICE - ExceptionHandler.handleException() : Exceptionjava.util.zip.ZipException: Not in GZIP formatoccurred while writing to channel null 2021-07-28 10:21:16,863 NIOThread@0 INFO HTTP.SERVICE - ExceptionHandler.handleException() : Exception trace: java.util.zip.ZipException: Not in GZIP format上述错误消息中的
java.util.zip.ZipException: Not in GZIP format行表明,该请求 虽然Content-Encoding和 以 gzip 格式指定因此,Apigee Edge 会抛出异常, 返回带有错误代码的400状态代码messaging.adaptors.http.flow.DecompressionFailureAtRequest。情景 #2
场景 2:当 API 请求包含 Content-Encoding: deflate 标头时
2021-07-28 15:26:31,893 NIOThread@1 ERROR HTTP.SERVER - HTTPServer$Context.onInputException() : Message id:rt-47875-1 SSLClientChannel[Accepted: Remote:192.168.199.8:8443 Local:192.168.81.72:45954]@29276 useCount=1 bytesRead=0 bytesWritten=37230 age=3498856ms lastIO=1ms isOpen=true.onExceptionRead exception: {}java.util.zip.ZipException: incorrect header check….Caused by: java.util.zip.DataFormatException: incorrect header check.. 2021-07-28 15:26:31,894 NIOThread@1 ERROR ADAPTORS.HTTP.FLOW - AbstractRequestListener.onException() : Request:POST, uri:/test, message Id:rrt-47875-1, exception:java.util.zip.ZipException: incorrect header check, context:Context@69b3ac45 input=ClientInputChannel(SSLClientChannel[Accepted: Remote:192.168.199.8:8443 Local:192.168.81.72:45954]@29276 useCount=1 byt esRead=0 bytesWritten=37230 age=3498856ms lastIO=1ms isOpen=true)线条
java.util.zip.ZipException: incorrect header check和Caused by: java.util.zip.DataFormatException: incorrect header check表示请求有效负载不是在 deflate 格式,并且它与 deflate 的Content-Encoding标头。因此,Apigee Edge 会抛出异常并返回400状态代码, 错误代码messaging.adaptors.http.flow.DecompressionFailureAtRequest。
-
分辨率
- 如果不需要在 Apigee Edge 的 API 代理流程中使用压缩的请求载荷
在后端服务器中,则不要传递标头
Content-Encoding。 如果需要压缩请求载荷,请转到第 2 步。 - 确保客户端应用始终发送以下内容:
<ph type="x-smartling-placeholder">
- </ph>
- 以下任何一项:
<ph type="x-smartling-placeholder"></ph>
支持编码作为
Content-Encoding标头的值, 请求 - Apigee Edge 支持的格式的请求载荷与编码格式匹配
Content-Encoding标头中指定的格式
- 以下任何一项:
<ph type="x-smartling-placeholder"></ph>
支持编码作为
- 在上面讨论的示例中,请求载荷采用 ZIP 格式,但请求标头
指定
Content-Encoding: gzip。您可以通过发送请求来解决此问题 标头显示为Content-Encoding: gzip,请求载荷也位于gzip中 格式:curl -v "https://HOSTALIAS/v1/testgzip" -H "Content-Encoding: gzip" -X POST -d @request_payload.gz
规范
Apigee Edge 返回状态代码 400 Bad Request 以及错误代码
messaging.adaptors.http.flow.DecompressionFailureAtRequest(根据以下 RFC)
规范:
| 规范 |
|---|
| <ph type="x-smartling-placeholder"></ph> RFC 7231,第 6.5.1 节 |
| <ph type="x-smartling-placeholder"></ph> RFC 7231,第 3.1.2.2 节 |
如果您仍然需要 Apigee 支持团队的任何帮助,请转到 必须收集诊断信息。
必须收集的诊断信息
请收集以下诊断信息,然后联系 Apigee Edge 支持团队:
如果您是公有云用户,请提供以下信息:
- 组织名称
- 环境名称
- API 代理名称
- 完成用于重现
400错误的curl命令 - API 请求的跟踪文件
如果您是 Private Cloud 用户,请提供以下信息:
- 观察到失败请求的完整错误消息
- 环境名称
- API 代理软件包
- API 请求的跟踪文件
NGINX 访问日志
/opt/apigee/var/log/edge-router/nginx/ORG~ENV.PORT#_access_log其中:ORG、ENV 和 PORT# 替换为 实际值。
- 消息处理器系统日志
/opt/apigee/var/log/edge-message-processor/logs/system.log