Questions tagged with Amazon API Gateway

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

HTTP API, ALB integration 5XX errors

Hi, I have below setup as I followed following tutorial : https://aws.amazon.com/blogs/compute/configuring-private-integrations-with-amazon-api-gateway-http-apis/ customdomain (my.domain.com) -> HTTPAPI -> VPC Link -> ALB -> ECS VPCLink: - VPC for ALB is used - Subnets for ALB are added - Security groups for ALB is added Integration: - ALB is selected - 443 HTTPS Listener is selected - VPC Link is selected Paramater Mapping for Integration: - path -> overwrite -> $request.path Routing: "ANY /{proxy}" route is added and integration is attached. Deployment: - "prod" stage is created, auto-deploy is enabled Route53: Domain (my.domain.com) is added as an A record pointing to custom domain When I make request using my.domain.com (same if I use auto generated stage url) I always get 503 errors. I checked and ECS instance is running properly and healthy. Sample access log : { "requestId": "Z6KDRhh0DoEEJhg=", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "sourceIp": "my_ip", "requestTime": "12/Oct/2022:20:29:34 +0000", "requestTimeEpoch": "1665606574", "httpMethod": "GET", "path": "/", "status": "503", "protocol": "HTTP/1.1", "responseLength": "33", "domainName": "my.domain.com", "integrationError": "-", "integrationDotError": "-", "integrationStatus": "200", "integrationDotStatus": "-", "integrationDotIntegrationStatus": "200", "integrationLatency": "9001" } What am I missing? Please help.
2
answers
0
votes
36
views
asked 2 months ago

API Gateway unable to stream back generated PDF due to encoding type

**I have posted updates below as I have gone through troubleshooting and bug fixing in regards to this problem.** I have a simple application that I have built that runs perfectly locally. A React front-end that takes some text inputs, and an Express backend that generates a PDF with the information, and streams back a PDF that is generated. The whole application works fine, as does testing a locally running as well as specifically hitting the endpoints using Insomnia running locally. The front-end is currently deployed in an S3 bucket being served through Cloudfront and is working fine. If I point an API request with Insomnia at my deployed API, the GET requests works fine, returning exactly what is expected, displaying the generated PDF in the content window. However when I make my POST request, I get some mixed messages. If I hit the POST in Insomnia I get back a 200, but the PDF that is returns is blank even though I verified that it did receive the POST body. If I use the deployed UI or my local UI pointing at the deployed API, I get a combination of errors. * Access to fetch at 'API ENDPOINT URL' from origin 'MY UI ORIGIN' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. * POST 'API ENDPOINT URL' net::ERR_FAILED * Uncaught (in promise) TypeError: Failed to fetch The second errors feel like false flags caused by possibly the first error. However I have CORS Enabled in my API Gateway and currently am allowing wildcarded access. And the GET request works fine. I also have enabled 'application/json' and 'application/pdf' in the Binary Media Types in the Gateway settings. I saw some posts from a few years ago indicating that API Gateway doesn't support streaming back a file but I am unsure if that is correct. If so, that means I need to come up with a different solution for serving up generated files to end users. Or if that has been changed, there is another error in my AWS implementation. **UPDATE**: I made some progress. For testing, I actually removed the OPTIONS method from my API Gateway. That actually removed the CORS errors, which was unexpected. The GET request stills functions as it did before and all responses come back as 200. However the PDF is malformed or corrupted. It still works locally, but the PDF coming back from the deployed API does not. I also get the same result from the Test function within API Gateway but can confirm it still works running locally. **UPDATED PROGRESS**: After removing the rest of what appeared to be false flag errors, it has come down to API Gateway having challenges with encoding type. After making sure to have binary types being set within the API Gateway, within my code base, and having Accept headers set on the client, the returned document still appears to be encoded improperly. That is where this question is at now, as I continue to work on it.
2
answers
0
votes
48
views
profile picture
asked 2 months ago

Websocket Api not working with authorzer lamda

I have been trying to fix this since days now but I've no clue what is happening I have created a websocket api using cdk which works fine but when I add authorzer to connect route I get 500 error. The authorizer lambda completes execution normally but the connect route lambda is never invoked import { WebSocketApi, WebSocketAuthorizer, WebSocketAuthorizerType, WebSocketStage } from '@aws-cdk/aws-apigatewayv2-alpha'; import { WebSocketLambdaAuthorizer } from '@aws-cdk/aws-apigatewayv2-authorizers-alpha'; import { WebSocketLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations-alpha'; `const authorizer = new WebSocketLambdaAuthorizer('blessed-messanger-authorizer', authorizerHandler , { identitySource: ['route.request.querystring.token'] } );` `this.webSocketApi = new WebSocketApi(this, 'blessed-messenger-api', { apiName: 'blessed-messenger', connectRouteOptions: { integration: new WebSocketLambdaIntegration("ConnectIntegration", onConnectHandler), authorizer }, defaultRouteOptions: { integration: new WebSocketLambdaIntegration("DefaultIntegration", onMessageHandler) }, disconnectRouteOptions: { integration: new WebSocketLambdaIntegration("DisconnectIntegration", onDisconnectHandler) }, });` This is my authorzer function. I have tried everything that is commented out in if block `exports.handler = async (event, context, callback) => { var queryStringParameters = event.queryStringParameters; var token = queryStringParameters.token; if(token === "some_user"){ // return generateAllow("some_user", event.methodArn); // callback(null, generateAllow("some_user", event.methodArn); return { statusCode: 200, body: "OK" }; }else{ callback("Unauthorized"); } };` I have read these questions as well but no luck https://repost.aws/questions/QUfTsKsL47RYSz9z1OAZEYMA/websocket-authorizer-status-500 Please help
1
answers
0
votes
41
views
asked 2 months ago

intermittent performance issues with the OpenSearch cluster

We are having intermittent performance issues with our OpenSearch cluster. There are multiple daily occurrences of long-running OpenSearch queries when executing our lambda function. When this occurs there is record like the example below in the Open Search es-application-logs 2022-09-09T11:37:35.083-04:00 [2022-09-09T08:37:34,853][WARN ][o.o.t.TransportService ] [09122640e72c461b2c57179fcc08d339] Received response for a request that has timed out, sent [44029ms] ago, timed out [24016ms] ago, action [__PATH__], node [{d52117a284ca0ada6bd69784bbd8a8c5} {ekzv2YqtT8q7b-TVvXGKEQ} {aGQCli5rTFKAeGjWRihvTQ} {_IP} {IP_} {dimr} {dp_version=20210501, distributed_snapshot_deletion_enabled=false, cold_enabled=false, adv_sec_enabled=true, _AMAZON_INTERNAL, cross_cluster_transport_address=IP, shard_indexing_pressure_enabled=true, __AMAZON_INTERNAL_} ], id [3986058] Normally these queries complete with sub second response times. The impact to our application is that occasionally requests to API Gateway are timing out due to the long running Lambda and results in 504 Gateway Timeout being returned to the API consumer. Here is an example of the OpenSearch HTTP request { "method": "POST", "hostname": "vpc-tycc-analytics-dev-os-qs4p2rpyars2oacibpdih4ctmu.ca-central-1.es.amazonaws.com", "query": { "size": "500", "_source": [ "CurrentAgentSnapshot" ], "sort": "CurrentAgentSnapshot.Configuration.Username:asc" }, "headers": { "Content-Type": "application/json", "host": "vpc-tycc-analytics-dev-os-qs4p2rpyars2oacibpdih4ctmu.ca-central-1.es.amazonaws.com" }, "body": "{\"query\":{\"bool\":{\"must_not\":{\"term\":{\"CurrentAgentSnapshot.Configuration.RoutingProfile.Name\":\"Basic Routing Profile\"}}}}}", "protocol": "https:", "path": "/agent-records-real-time-alias/_search" } Are you able to please investigate and provide feedback as to what is causing the performance issue along with remediation action. Let me know if you require additional information. Thanks, BTW The following is out cluster specification: • Deployment type: Dev/Test • OS version: 1.2 (latest) • Availability Zones: 1AZ • Instance type: t3.small.search • Number of nodes: 2 • Storage type: EBS • EBS volume type: General Purpose (SSD) - gp2 EBS storage size per node: 10 GB
1
answers
0
votes
45
views
asked 2 months ago