I'm using API Gateway to create a REST API where I can run my API which is hosted via docker and jenkins, setup on aws ec2.
But whenever I try to send the request through API Gateway, I get the error of 504
The error message on API Gateway
However, when I hit the API through postman, I'm able to get a successful GET Request.
Successful message on Postman
This is how I know I'm hitting the correct API successfully but I'm not able to figure out why I'm getting a 504 error message on API Gateway.
Make sure that your backend integration includes only the logic needed for API Gateway to send an HTTP response to the client. Consider moving any nondependent or post-processing logic to another service, such as AWS Lambda.
If network latencies are causing the 504 error, implement retry logic on the client-side application.
Related
I am trying to use AWS Lambda function with API gateway endpoint as weebhoks. The problem is that after a few requests I get 500 (or sometimes 503) errors. In Cloudwatch I can see that the request does not even trigger Lambda. So API gateway throws the errors. If I am waiting a short time then it everyhting is working fine again.
In Cloudwatch of API gateway I can only see the error status, no more.
I have an API Gateway, integrated to a Step Function, inside a VPC.
When I hit the endpoint the step function is successfully executing, but it's still replying with:
500 Internal Server Error
{
"message": "Internal server error"
}
Everything is setup in terraform, have tried setting up a response in terraform and on the console but both aren't working.
screenshot: https://pasteboard.co/Kikasjb.png
note, looked at this post: AWS API Gateway - Lambda - Internal Server Error
It's similar but there the reply is around a lambda returning a value, but this step function is asynchronous so not sure how something gets send back here. Thanks!
I discovered my issue was that when settings in the API Gateway in the console I have to redeploy the API gateway before being able to test the change.
I'm not able to find any documentation about intercepting all HTTP requests passing through AWS API Gateway.
I'm trying to propose a Logging service for the backend APIs deployed on AWS API Gateway. The idea is all the HTTP requests will go through the API Gateway. If I'm able to intercept the request going through API Gateway, I can hook the logging service code.
The reason for this approach is, the logging code will be independent of the actual service code and service code won't have to be updated to include logging of request / response.
Any solutions for this?
You can put CloudFront in front of your API Gateway and then use Lambda#Edge Viewer Request to intercept all requests; we do this for logging for certain functions and it works flawlessly.
This is a good tutorial on how to setup API Gateway with CloudFront
https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudfront-distribution/
It seems Claudia-bot-builder's intercept method will help you to intercept the API gateway requests. You can trigger an event for requests hitting to the API gateway.
`api.intercept(function (event) { ... });`
I have set up an API on AWS API gateway with HTTP proxy
https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/dev
This API is in front of the public DNS of ALB:
http://xxxxxx.us-east-1.elb.amazonaws.com
ALB direct the traffic to different microservices (ms1, ms2, dummy), where ms1 and ms2 will take POST method to /ms1 and /ms2, and dummy one will take any other request (means GET and POST to any /* other than /ms1 and /ms2) to return some default response.
When I test the API in API gateway, it works fine. But when I do it in postman, I can do the POST to ms1 and ms2 from https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/ms1 and https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/ms2, but can not do https://xxxxxxxx.execute-api.us-east-1.amazonaws.com/dev via GET and POST (this works at the testing in API gateway). The error message is:
{
"message": "No method found matching route / for http method GET."
}
I set up the AWS authentication in POSTMAN, so it should not be an issue. I guess I may miss some things in the header. Any thoughts?
I want to submit a GET request using Authorization and Content-Type(application/json) as headers. Authorization would contain "Bearer " + token.
I am using Lambda function as to trigger when user hits this API endpoint. As this is get request, I am sending body = undefined in parameters.
But since 4-5 hours I am getting "internal server error" as of status code =502.
I noticed that these requests are due to bad gateway, still they are captured in cloudwatch logs.
The thing is, I want to know how to setup a GET request in AWS API gateway as I have not much experience in this technology.