Use REST API in API gateway to implement websocket connection to the backend ECS service

0

Hi,

We're trying to use REST API in API Gateway to establish websocket connections with our backend ECS services. We added headers below to the method request and the integration request. But the headers were changed when they reached our backend. Especially the Connection became Keep-Alive. Is there a way to keep the headers for websocket upgrade?

  • Connection: Upgrade
  • Upgrade: websocket
  • Sec-WebSocket-Key: <replace with key>
  • Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
  • Sec-WebSocket-Version: 13

If REST API doesn't support websocket connection, how shall we use WebSocket API in API Gateway to establish websocket connections when the client is behind a firewall and doesn't allow wss traffic?

  • Worth replacing the REST API over a WebSocket API. ?

1 réponse
1
Réponse acceptée

API Gateway only support web sockets from the client to the gateway. From the gateway to the backend integration, ECS in your case, it does not support web sockets. You will need to use an HTTP integration type (or VPC Link if the ECS cluster is private).

If your client is not able to established a web socket with the gateway due to firewalls, they may need to revert to polling instead.

I am not sure why you are trying to create a web socket connection from API Gateway to the backend, if the client does not support it anyway.

profile pictureAWS
EXPERT
Uri
répondu il y a 7 mois
profile picture
EXPERT
vérifié il y a un mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions