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개 답변
1
수락된 답변

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
전문가
Uri
답변함 7달 전
profile picture
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인