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. ?

gefragt vor 7 Monaten683 Aufrufe
1 Antwort
1
Akzeptierte Antwort

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
EXPERTE
Uri
beantwortet vor 7 Monaten
profile picture
EXPERTE
überprüft vor einem Monat

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen