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

已提问 7 个月前684 查看次数
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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则