Skip to content

Does ApiGateway WebSocket Splits Messages at 4 KB?

2

Hi AWS,

Here is the context:

I have a websocket on api gateway. What it does is acting like a proxy, exchanging messages between different clients( UI and embedded systems). I'm generating some payload from the browser (Client A) and send it using method ApiGatewayManagementApiClient::PostToConnectionCommand via Lambda to the receiver's ConnectionID (Client B). I expect when the receiver (Client B) gets the payload to generate a response. It has been tested to work fine with short payloads less than 4 KB. But it would crash Client B when I send a payload larger than 4KB from the UI. It is likely because the websocket lib in clientB is not capable of handling fragmented message. According to AWS documentation they have a maximum frame size of 32 KB. My full message is around 5~6 KB, so I expect that it is going to be sent at once. Unfortunately this doesn't seem to be the case my message is split to 4 KB fragments.

So my question is: Is it possible that AWS API Gateway is splitting my message in 4KB chunks (or Lambda does it) and if it is so is it possible to somehow increase this limit so I receive the whole message at once instead?

Any help will be appreciated.

1 Answer
0

As you have already pointed out that based on your message size of around 6kb-8kb. Apigateway could still accept this message since it has a max size at 32KB. So I feel that you now have to check the browser agent used, various browsers have different limits, most common is 4KB by default. You can extend this in for your browser like firefox has his changeable via the about:config property network.websocket.maxMessageSize. Or in other means you can still try to figure our some mechanism to split your messages and sent and aggregate them in chunks of 4K to be compatible with most clients. Let me know if that helps firefox screenshot

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.