You're viewing Apigee Edge documentation.
Go to the
Apigee X documentation. info
Symptom
The client application gets an HTTP status code of 502 Bad Gateway
with error code
messaging.adaptors.http.flow.DecompressionFailureAtResponse
as a response to API
calls.
Error message
Client application gets the following response code:
HTTP/1.1 502 Bad Gateway
In addition, you may observe an error message similar to the one shown below:
{ "fault":{ "faultstring":"Decompression failure at response", "detail":{ "errorcode":"messaging.adaptors.http.flow.DecompressionFailureAtResponse" } } }
Possible causes
This error occurs only if:
- The encoding specified in the HTTP response (from the backend/target server) header
Content-Encoding
is valid and supported by Apigee Edge, - The payload format sent by the backend/target server as part of the HTTP response
does not
match the encoding format specified in the
Content-Encoding
header
BUT
This is because Apigee Edge fails to decode the payload using the specified encoding since the
format of the payload is not in the same format as the encoding specified in the
Content-Encoding
header.
Here are few examples of supported Content-Encoding
values and how Apigee Edge
expects the payload representation to be in those cases:
Scenario | Content-Encoding | Payload representation |
---|---|---|
Single Encoding | gzip | The Unix See RFC1952 GZIP Format. |
Single Encoding | deflate | This format uses |
Multiple Encoding | Multiple Encoding For example, in cases when the encoding is done twice, it can be:
|
Multiple encoding applied to the payload in the given order as it appears in the header. |
The possible causes for this error are as follows:
Cause | Description | Troubleshooting instructions applicable for |
---|---|---|
Response payload format does not match the Content-Encoding | The format of the response payload sent by the backend/target server is either
not encoded or does not
match the encoding specified in the Content-Encoding header. |
Edge Public and Private Cloud users |
Common diagnosis steps
Use one of the following tools/techniques to diagnose this error:
API Monitoring
To diagnose the error using API Monitoring:
- Sign in to Apigee Edge UI as a user with an appropriate role.
Switch to the organization in which you want to investigate the issue.
- Navigate to the Analyze > API Monitoring > Investigate page.
- Select the specific timeframe in which you observed the errors.
- Ensure that the Proxy filter is set to All.
- Plot Fault Code against Time.
Select a cell which has the fault code
messaging.adaptors.http.flow.DecompressionFailureAtResponse
as shown below:Information about the fault code
messaging.adaptors.http.flow.DecompressionFailureAtResponse
is displayed as shown below:Click View logs and expand the row failing with the
502
error.- From the Logs window, note the following details:
- Status Code:
502
- Fault Source:
target
- Fault Code:
messaging.adaptors.http.flow.DecompressionFailureAtResponse
.
- Status Code:
- If the Fault Source has the value
target
, then that indicates that the response payload format did not match the supported encoding specified in the backend server's response headerContent-Encoding
.
Trace tool
To diagnose the error using the Trace tool:
- Enable the trace session
and either:
- Wait for the
502 Bad Gateway
error to occur, or - If you can reproduce the issue, make the API call and reproduce
502 Bad Gateway
.
- Wait for the
Ensure Show all FlowInfos is enabled:
- Select one of the failing responses and examine the trace.
- Navigate through different phases of the trace and locate where the failure occurred.
You will typically find the error in a flow right after the Response Received from target server phase as shown below:
-
Note the values of the properties from the trace:
- Content-Encoding:
gzip
- Response Content Body:
{"fault":{"faultstring":"Decompression failure at response","detail":{"errorcode":"messaging.adaptors.http.flow.DecompressionFailureAtResponse"}}}
- Content-Encoding:
Navigate to error phase just after the Response Received from target server phase:
Note the properties:
- error:
Decompression failure at response
- error.class:
com.apigee.errors.http.server.BadGateway
error.cause:
Not in GZIP format
The error.cause states that the response payload is Not in GZIP format. This means that Apigee Edge was expecting the response payload to be in GZIP format as was specified in the
Content-Encoding
header (determined in previous step).Therefore, Apigee Edge cannot decompress the payload using gzip and returns the errorDecompression failure at response
.
Note that the response from the target/backend server is
200
in this case; however, the client application will receive a502
response since the error is returned by Apigee Edge.- error:
Navigate to the Response Sent to Client phase in the trace and click it.
Note the following details from the trace:
- Status code:
502 Bad Gateway
. - Error Content:
{"fault":{"faultstring":"Decompression failure at response","detail":{"errorcode":"messaging.adaptors.http.flow.DecompressionFailureAtResponse"}}}
- Status code:
Navigate to the AX (Analytics Data Recorded) phase in the trace and click it.
- Scroll down to the Phase Details, Error Headers section and determine the values of X-Apigee-fault-code and X-Apigee-fault-source as shown below:
- You will see the values of X-Apigee-fault-code and X-Apigee-fault-source
as
messaging.adaptors.http.flow.DecompressionFailureAtResponse
andtarget
, indicating that the response payload format did not match the encoding specified in theContent-Encoding
header.Response headers Value X-Apigee-fault-code messaging.adaptors.http.flow.DecompressionFailureAtResponse
X-Apigee-fault-source target
NGINX
To diagnose the error using NGINX access logs:
- If you are a Private Cloud user, then you can use NGINX access logs to
determine the key information about HTTP
502
errors. Check the NGINX access logs:
/opt/apigee/var/log/edge-router/nginx/ORG~ENV.PORT#_access_log
Where: ORG, ENV, and PORT# are replaced with actual values.
- Search to see if there are any
502
errors during a specific duration (if the problem happened in the past) or if there are any responses still failing with502
. If you do find any
502
errors with the X-Apigee-fault-code matching the value ofmessaging.adaptors.http.flow.DecompressionFailureAtResponse
, then determine the value of the X-Apigee-fault-source.Sample 502 error from NGINX access log:
The above sample entry from the NGINX access log has the following values for X-Apigee-fault-code and X-Apigee-fault-source:
Response headers Value X-Apigee-fault-code messaging.adaptors.http.flow.DecompressionFailureAtResponse
X-Apigee-fault-source target
Cause: Response payload format does not match the Content-Encoding
By default, Apigee Edge always decompresses the payload if the response header
Content-Encoding
contains a valid and a
supported encoding. Therefore, it is expected that the format of the response payload
should match the encoding specified in the response header Content-Encoding
.
If there is a mismatch, then you get this error.
Diagnosis
- Determine the Fault Code and Fault Source for the error observed using API Monitoring, Trace tool, or NGINX access logs as explained in Common diagnosis steps.
- If the Fault Code is
messaging.adaptors.http.flow.DecompressionFailureAtResponse
and the Fault Source has the valuetarget
, then this indicates that the format of the response payload sent by the backend/target server does not match the supported encoding specified in the response headerContent-Encoding
. You can determine the mismatch as part of the HTTP response using one of the following methods:
Error message
To validate using the error message:
-
If you have access to the complete error message received from Apigee Edge, then refer to the
faultstring
.Sample error message:
"faultstring":"Decompression failure at response"
- In the above error message, it displays
"Decompression failure at response"
which implies that the response could not be decompressed using the encoding specified in theContent-Encoding
header.
Trace
To validate using the Trace:
- Determine the Content-Type and error.cause using Trace as explained in Common diagnosis steps.
The values from the sample trace are as follows:
- Content-Encoding:
gzip
- error.cause:
Not in GZIP format
The value in the response header Content-Encoding is gzip; however, the response payload is not in GZIP format (as indicated by error.cause). Therefore, Apigee Edge responds with
502 Bad Gateway
and error codemessaging.adaptors.http.flow.DecompressionFailureAtResponse
.- Content-Encoding:
Actual request
To validate using the actual request:
If you have access to the actual request made to the target/backend server application, then perform the following steps:
- If you are a Public Cloud/Private Cloud user, make a request directly to the backend server from the backend server itself or any other machine from where you are allowed to make the request to the backend server.
- If you are a Private Cloud user, you can also make the request to the backend server from one of the Message Processors.
- Examine the response sent by the backend server and determine the value
passed in the response header
Content-Encoding.
- Determine the format of the payload sent as part of the request.
- If the value of
Content-Encoding
header is in the list of supported encoding but the format of the response payload does not match with the encoding specified inContent-Encoding
header, then that is the cause of the issue.Sample:
curl -v https://HOSTALIAS/test
***trimmed*** > < HTTP/1.1 200 OK < Accept-Ranges: bytes <
Content-Encoding: gzip
< Date: Mon, 02 Aug 2021 08:17:35 GMT < Transfer-Encoding: chunked < < response_payload.zip Response Body(not in GZIP format)>The above sample response sends the value
gzip
to theContent-Encoding
header which is a supported encoding in Apigee Edge. However, theresponse_payload.zip
is sent as a zip file. Therefore, this response fails with a502 Bad Gateway
error with the error code:messaging.adaptors.http.flow.DecompressionFailureAtResponse
.
Message Processor logs
To validate using Message Processor logs:
If you are a Private Cloud user, then you can use Message Processor logs to determine the key information about HTTP
502
errors.Check the Message Processor log:
/opt/apigee/var/log/edge-message-processor/logs/system.log
Search to see if there are any
502
errors during a specific duration (if the problem happened in the past) or if there are any responses still failing with502
. You may use the following search string:grep -ri "ZipException"
You will find lines from system.log similar to the following:
Scenario #1
Scenario #1: When API response has the header Content-Encoding: gzip
2021-08-02 06:50:25,433 NIOThread@2 ERROR HTTP.CLIENT - HTTPClient$Context.onInputException() : ClientInputChannel(ClientChannel[Connected: Remote:3.8.1.1:9000 Local:10.0.115.32:41298]@38140 useCount=1 bytesRead=0 bytesWritten=203 age=469ms lastIO=0ms isOpen=true).onExceptionRead exception: {}
java.util.zip.ZipException: Not in GZIP format
---trimmed-- 2021-08-02 06:50:25,433 NIOThread@2 INFO HTTP.CLIENT - HTTPClient$Context.logContextDetails() : Request details : host=null path=/folder/testFile method=GET. Channel details : Bytes read=0 2021-08-02 06:50:25,434 NIOThread@2 ERROR ADAPTORS.HTTP.FLOW - AbstractResponseListener.onException() : AbstractResponseListener.onError(HTTPResponse@4806fdab, Not in GZIP format) 2021-08-02 06:50:25,434 NIOThread@2 INFO HTTP.SERVICE - ExceptionHandler.handleException() : Exceptionjava.util.zip.ZipException: Not in GZIP format
occurred while writing to channel null 2021-08-02 06:50:25,434 NIOThread@2 INFO HTTP.SERVICE - ExceptionHandler.handleException() : Exception trace: java.util.zip.ZipException: Not in GZIP formatThe line
java.util.zip.ZipException: Not in GZIP format
in the above error message indicates that the response payload is not sent in GZIP format although theContent-Encoding
is specified as gzip. Therefore, Apigee Edge throws the exception and returns a502
status code with fault codemessaging.adaptors.http.flow.DecompressionFailureAtResponse
to client applications.Scenario #2
Scenario #2: When API response has the header Content-Encoding: deflate
2021-08-02 06:35:21,215 NIOThread@0 ERROR HTTP.CLIENT - HTTPClient$Context.onInputException() : ClientInputChannel(ClientChannel[Connected: Remote:3.8.1.1:9000 Local:192.168.194.140:35224]@36014 useCount=1 bytesRead=0 bytesWritten=202 age=439ms lastIO=2ms isOpen=true).onExceptionRead exception: {}
java.util.zip.ZipException: incorrect header check
---trimmed---- Caused by:java.util.zip.DataFormatException: incorrect header check
---trimmed--- 2021-08-02 06:35:21,215 NIOThread@0 INFO HTTP.CLIENT - HTTPClient$Context.logContextDetails() : Request details : host=null path=/folder/testFile method=GET. Channel details : Bytes read=0 2021-08-02 06:35:21,216 NIOThread@0 ERROR ADAPTORS.HTTP.FLOW - AbstractResponseListener.onException() : AbstractResponseListener.onError(HTTPResponse@3966e277, incorrect header check) 2021-08-02 06:35:21,216 NIOThread@0 INFO HTTP.SERVICE - ExceptionHandler.handleException() : Exception java.util.zip.ZipException: incorrect header check occurred while writing to channel null 2021-08-02 06:35:21,217 NIOThread@0 INFO HTTP.SERVICE - ExceptionHandler.handleException() : Exception trace: java.util.zip.ZipException: incorrect header checkThe lines
java.util.zip.ZipException: incorrect header check
andCaused by: java.util.zip.DataFormatException: incorrect header check
in the above error message indicate that the response payload is not sent in deflate format and does not match the encoding specified in theContent-Encoding
header of deflate. Therefore, Apigee Edge throws the exception and returns a502
status code with fault codemessaging.adaptors.http.flow.DecompressionFailureAtResponse
to client applications.
-
Resolution
- If there's no need for the compressed response payload in the API proxy flow in Apigee Edge
and in the backend server, then do not pass the header
Content-Encoding
. If there is a need to compress the response payload, go to step 2. - If there's a need to compress the response payload, then ensure that the backend server
always sends the following:
- Any of the
supported encoding as the value for the
Content-Encoding
header in the response - The response payload in the supported format to Apigee Edge matches the encoding
format specified in the
Content-Encoding
header
- Any of the
supported encoding as the value for the
- In the example discussed above, the response payload is in ZIP format but the response header
specifies
Content-Encoding: gzip
. You can fix the issue by sending the response header asContent-Encoding: gzip
and the response payload ingzip
format:curl -v https://HOSTALIAS/v1/test
> < HTTP/1.1 200 OK < Accept-Ranges: bytes <
Content-Encoding: gzip
< Date: Mon, 02 Aug 2021 08:17:35 GMT < Transfer-Encoding: chunked < < response_payload.gz Response Body(in GZIP format)>
Specification
Apigee Edge responds with the status code 502 Bad Gateway
with error code
messaging.adaptors.http.flow.DecompressionFailureAtResponse
as per the following RFC
specifications:
Specification |
---|
RFC 7231, section 6.5.1 |
RFC 7231, section 3.1.2.2 |
If you still need any assistance from Apigee Support, go to Must gather diagnostic information.
Must gather diagnostic information
Gather the following diagnostic information, and then contact Apigee Edge Support:
If you are a Public Cloud user, provide the following information:
- Organization name
- Environment name
- API Proxy name
- Complete
curl
command used to reproduce the502
error - Trace file for the API responses
If you are a Private Cloud user, provide the following information:
- Complete error message observed for the failing responses
- Environment name
- API Proxy bundle
- Trace file for the API responses
NGINX access logs
/opt/apigee/var/log/edge-router/nginx/ORG~ENV.PORT#_access_log
Where: ORG, ENV and PORT# are replaced with actual values.
- Message Processor system logs
/opt/apigee/var/log/edge-message-processor/logs/system.log