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
エキスパート
レビュー済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ