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

3 Risposte
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
con risposta 5 anni fa
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
con risposta 5 anni fa
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
con risposta 5 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande