Ir para o conteúdo

Websocket $connect route: headers and querystring empty on http integration

0

I am using Websocket API that uses HTTP integration to communicate with my NodeJS Backend in EC2. I managed to pass on the connectionId on the $connect route using a Request Template.
However when I do this, I am unable to pass on any custom header and querystring parameters. I have tried to pass these values using the Request Template by using the $request.querystring and the $input.params parameters. But this did not work.

When the 'Use HTTP Proxy integration' is checked both the querystring and the custom headers are correctly passed on to the backend, but then the connectionId is not passed on.

My current Request Template is:

{
  "connectionId": "$context.connectionId",
  "domain": "$context.domainName",
  "stage": "$context.stage",
  "requestId": "$context.requestId",
  "body": "$input.body"
}

My question is, if it is possible to pass on querystring parameters/custom headers as well as the connectionId in the $connect route ?

feita há 7 anos1,4 mil visualizações

2 Respostas
0
Resposta aceita

At the time of writing, WebSocket API does not support query strings or headers in the template. You can take a look all supported variables here:
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-mapping-template-reference.html

I agree that it makes sense to support query strings/headers in the template for the $connect route while it does not for other routes. I'll create a backlog for this.

AWS

respondido há 7 anos

ESPECIALISTA

avaliado há 2 anos

0

how is this solved? can you share a way to do this right

respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.