Application Load Balancer 502 ERROR when sending raw binary body

0

We have a legacy client that sends binary requests to the server. We want to put ALB in front of this but all those requests are getting dropped by ALB. If we base64 the data before sending, it is forwarded to the target group just fine. But since we need to support legacy clients that are embedded on the devices, this is difficult to handle. Is this a limitation of ALB or is there a workaround?

asked 2 months ago49 views
2 Answers
1
Accepted Answer

The issue you're experiencing with the Application Load Balancer (ALB) dropping binary requests is indeed a limitation of ALB's default behavior. However, there are potential workarounds to handle this situation:

  1. Binary Support Configuration: Ensure that binary support is properly configured in your ALB settings. You may need to add the appropriate media types (such as application/octet-stream) to the API's binaryMediaTypes list if you're using API Gateway in conjunction with ALB.

  2. Content Handling: If you're using API Gateway, set the contentHandling property of the Integration resource to CONVERT_TO_BINARY. This can help in properly handling binary content.

  3. Lambda Function as Intermediary: You could use a Lambda function as a target for your ALB. In this setup, the Lambda function can receive the raw binary data, process it as needed, and then forward it to your actual server. The Lambda function would need to be configured to handle binary data correctly.

  4. Custom Domain Configuration: If you're using a custom domain with API Gateway, verify that the Binary Media Types are correctly set in the Custom Domain Name configuration.

  5. CloudFront with Lambda@Edge: Consider using Amazon CloudFront with Lambda@Edge in front of your ALB. This combination can give you more flexibility in managing and transforming requests before they reach the ALB.

  6. Target Group Configuration: Ensure your target group is correctly configured to handle the type of traffic you're sending. For example, if your server is expecting HTTP traffic on port 80, make sure the target group is set up accordingly.

Remember, the exact solution may vary depending on your specific setup and requirements. If these workarounds don't resolve the issue, you might need to examine your entire request/response flow to identify where the binary data is being mishandled or dropped.
Sources
Remove Base 64 Encoding on ALB response | AWS re:Post
HTTPS Target Group 502 Error | AWS re:Post
Use Lambda functions as targets of an Application Load Balancer - Elastic Load Balancing

profile picture
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • Thank you for the quick response! Yes I am using Lambda Function as Intermediary, and the request is getting dropped by the ALB and the Lambda Function does not get the request. The same request comes through fine if the body is encoded base64.

0

Hello.

If you want to send binary data to Lambda, you might want to use API Gateway.
The API Gateway provides an option to handle binary data.
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings.html

profile picture
EXPERT
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions