Websocket response error, but successfull Post to connections

0

Hey all,

I'm having an issue with websockets. After I send my sendmessage action, which in turn just retrives the list of connections from dynamodb and uses the api gateway management api to post the message to said connections, the original sender of the message receiveds this error: {"message": "Internal server error", "connectionId":"fP6kAdMGvHcCE0g=", "requestId":"fP60AHLfvHcFfSA="}

I initially had the same return type as my REST endpoints (APIGatewayProxyResponse and error), then I change it to just be a string, then I changed it to not return anything at all. All three of these attempts didn't work.

Any ideas? I can't find a response structure for api gateway websockets anywhere on the interwebz.

Edited by: AustinK on Aug 30, 2019 12:13 PM

AustinK
已提問 5 年前檢視次數 1270 次
3 個答案
1

It sounds your Lambda function for sendmessage doesn't complete correctly after invoking postToConnection. By default, API Gateway invokes Lambda synchronously, and will wait until your Lambda sends a response. Eventually it will be timed out(either on Lambda's task timeout or API Gateway's integration time out), then API Gateway will let the original sender know the message wasn't completed correctly. You could confirm it by checking API Gateway's execution log and Lambda's log.

If you're using Lambda non-proxy integration, you can invoke it asynchronously.
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html

If you're using Lambda proxy integration, invoke a second lambda asynchronously from the first synchronous lambda then return a response immediately.

AWS
已回答 5 年前
1

So the issue was an error with how I was handling channels for my goroutine. Just wanted to say that so the thread isn't left unanswered.

AustinK
已回答 5 年前
0

So I'm using the golang example that they aws created.
https://aws.amazon.com/blogs/compute/announcing-websocket-apis-in-amazon-api-gateway/

The intergration type is AWS_PROXY, invoking a lambda function directly. So I'm assuming I'm using proxy integration? The example doesn't have anything invoking a second method to return a response.

I'm not sure where to go from here. I think I need a bit more hand holding.

NOTE: There were no error logs in cloudwatch.

Edited by: AustinK on Aug 30, 2019 1:37 PM

AustinK
已回答 5 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南