-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(@aws-cdk/aws-apigatewayv2): {message:"Internal server error",...} #18208
Comments
I've reproduced the issue with the code updated above, CLI version 1.137.0. Then get the wss endpoint or API id from API Gateway and use something like: wscat -c wss://abc123.execute-api.eu-central-1.amazonaws.com/production Then enter a message and receive: {"message": "Internal server error", "connectionId":"...", "requestId":"..."} |
I've also reproduced it with cli version 2.3.0 and the following changes in imports: test123-stack.js import { Stack } from 'aws-cdk-lib'
import { WebSocketApi, WebSocketStage } from '@aws-cdk/aws-apigatewayv2-alpha'
import { WebSocketLambdaIntegration } from '@aws-cdk/aws-apigatewayv2-integrations-alpha'
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' test123.js import {App} from 'aws-cdk-lib' "devDependencies": {
},
"dependencies": {
"@aws-cdk/aws-apigatewayv2-alpha": "^2.3.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.3.0-alpha.0",
"aws-cdk-lib": "^2.3.0",
"constructs": "^10.0.17"
} |
Figured it out; apparently you now have to make an integration per route when using the same function for all routes. |
|
Why is this ticket closed? "you now have to make an integration per route when using the same function for all routes" sounds like a workaround to a bug and isn't a real fix to a bug. This used to work in CDK v1. Now in CDK v2, when I look at the CloudFormation template that CDK creates, v2 is creating the BTW, I see that this issue was partially fixed. It was fixed for |
Any updates on this? |
update this pls |
What is the problem?
A websocket message {message:"Internal server error",...} is returned when sending any message to a websocket, or when disconnecting. Only the $connect route works, and posting messages from the lambda function through the management API.
Adding the new @aws-cdk/aws-apigatewayv2-authorizers caused an error apparently related to a version conflict, so I upgraded the modules to 1.137.0, after which the issue started to occur. It worked before but had been abandoned while I worked on other parts in a local environment, so there might be other factors.
I reduced the stack to just a websocket API with 1 stage and trivial lambda integration on $connect/$disconnect/$default routes, but the issue persisted. The issue does not occur when you create such a setup through the AWS console.
Destroying/redeploying the stack several times, or downgrading the modules to 1.123.0 again, running yarn and destroying/redeploying did not resolve the issue. Also with 2.3.0 CLI and 1.137/1.123 modules.
In Custom Access Logging, I log pretty much everything, but there is no indication what causes the internal server error. The lambda handler never gets called.
The only hint of difference that I have is when you run:
aws apigatewayv2 get-integrations --api-id xx
The console-created API returns 3 (similar) integrations, while the CDK-created API returns 1; all like this:
Again, the console API returns an array with 3 of those objects, having only different integrationIds, while the CDK version returns only 1.
The issue happens in other stacks as well, but could be an AWS issue rather than CDK, even through it does not occur in a manual console API. I filed a case with premium support.
Reproduction Steps
I've reproduced it using this code:
index.js:
package.json:
bin/test123.js:
lib/test123-stack.js:
What did you expect to happen?
Be able to send websocket messages without issues, like before.
What actually happened?
Can't send messages from client to websocket lambda integration handler - code is only called on connect route.
CDK CLI Version
1.137.0 (build bfbdf64) and tried with 2.3.0 and 1.123.0
Framework Version
No response
Node.js Version
14.18.2
OS
Ubuntu 20
Language
Typescript
Language Version
ES 2020
Other information
No response
The text was updated successfully, but these errors were encountered: