Hey I have a web socket deployed to AWS API gateway with a custom domain and lambda's backing it. I keep getting this error in web console when trying to interact with it through my angular app:
WebSocket connection to 'wss://customDomain/' failed: Error during WebSocket handshake: Unexpected response code: 403
I am not seeing anything in logs for API Gateway like anything is trying to hit it, and no function invocations on the lambda side.
I have a deployment for the gateway and best I can tell everything is setup correct. I am trying to move this apigateway from a shared legacy AWS account into a new one using the AWS-CDK so I can confirm from the code level that the setup should be correct.
The error here was caused by the API gateway needing to be deployed. After adding the custom domain, I created a new deployment for the stage that was assigned to the custom domain.
When using CDK, you can also set the stage to auto deploy on changes by setting autoDeploy: true in your CfnStage definition. This was what I ultimately did.
In addition to Jared's answer (which I'm grateful for as I was stumped for days) this is an example of what it would look like in your code if using WebSocketStage from @aws-cdk/aws-apigatewayv2-alpha:
new WebSocketStage(scope, 'WebSocketStage', {
webSocketApi,
stageName: 'your-env-name',
autoDeploy: true,
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With