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.
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'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.
I am getting below response when I hit AWS API gateway.
502: Bad Gateway
{
"message": "Internal server error"
}
I know that API gateway request payload limit is 10MB and I haven't exceeded that, but response size might be beyond 10 MB. Can response size affect?
Could find nothing in CloudWatch, not even getting logs related to this invocation.
Tried to follow this, but could find nothing.
First, Try to test your lambda function by invoking it in the api gateway Console or in the test part in the lambda console.
If the lambda function works, then maybe its a problem related to the parameters, content ( Integration request / response) or the permissions of the API Gateway + lambda.
Check also the time out of the lambda /!\
I have an .Net Core 3.1 web service running as a Lambda at AWS. The Lambda has is fronted by an API Gateway.
I left one of the routes unsecured for testing, /states. When I call /states without a bearer token I get the list of states. When I call it with a bearer token, I get a 502: Bad Gateway.
Another route requires a bearer token, /countries. When I call /countries with out a bearer token I get 401: Unauthorized. When I call /countries with a bearer token I get 502: Bad Gateway.
There doesn't seem to be anything in logs about what is happening.
Any Ideas? Thank you.
I got exactly the same symptoms and the reason behind them turned out to be Lambda function timeout.
Once Authorization: Bearer ... is present in the request for the first time, the request to the .NET app took longer to process (probably due to some middleware initialization). That made the app exceed the default 3 second timeout, which makes API Gateway return 502 error status code.
I'm new to AWS and Node so I really appreciate everyone's suggestion on this one. Recently in my system, something strange happened. Sometimes (~20 times/ month), a lambda request got timeout. It's just a simple request in middleware for authentication (I'm using node.JS serverless). The issues is I cannot trace this request from API gateway. Sorry I'm suck at explaining things so I'm gonna put it like this:
My system's flow: CloudFront -> API Gateway -> Lambda -> RDS
Normally if I want to trace a request:
I get the requestID from Lambda's Log
And search it in the API Gateway's Log:
But for these Timeout request:
I cannot find anything at all in API Gateway's Log:
Like it appeared out of nowhere... Please help and thanks for the suggestion.
You may already be aware but API Gateway has a hard max timeout limit of 29 seconds and stops waiting for the integration to respond after that time.
The Request ID that you are pulling from the lambda logs is the lambda request ID. This is a bit of speculation but I'm guessing since the Lambda took longer than 29 seconds and never returned to API Gateway since API Gateway timed out and stopped waiting, the API Gateway never received a response from the Lambda function to know what the lambda request ID is.
There still should be some API Gateway logs for this invocation but it won't contain any of the normal integration response log lines because it never received a response from the lambda integration.
Perhaps try searching for 504 in the API Gateway logs since this is the response code when the gateway times out.
Or as AADProgramming recommends, the X Ray service was designed to help users track requests across many services so enabling that would be helpful here.