API Gateway Websockets size limit Feedback


Why is the APi gateway websockets size limit so low (128k)?

This is pretty small, and frustrating.

Also, when you try and send too much data to the client, it didn't give me any errors the response just doesn't go through (lambda and websockets both logging a success).

It's a pretty cool service otherwise. Thanks for developing it!

7 Answers


answered 3 years ago

API Gateway responds back with error code 1009 when it receives a larger frame or message as mentioned here - https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html.

I don't understand what you mean by "the response doesn't go through"? Do you mean the request doesn't go through to your lambda integration? What logs do you see for your API when you send a large message?

answered 3 years ago

That may be what the documentation says, but from what we've seen in our use, that is not the case and it doesn't reply at all (as mentioned in the original post)

answered 3 years ago

This looks like a WS client issue. I tried with websockets (python), websocket-client (python) and wscat.

Working client : websocket and asyncio (python)

async def hello():
    uri = "wss://<api>.execute-api.us-west-2.amazonaws.com/<stage>/"
    async with websockets.connect(uri, ssl=ssl._create_unverified_context()) as websocket:
        name = "<some large msg>"

        await websocket.send(name)
        print(f"> large")

        greeting = await websocket.recv()
        print(f"< {greeting}")

Exception : websockets.exceptions.ConnectionClosedError: code = 1009 (message too big), reason = Message too big

Clients eating away the err code :
websocket-client (python)

def withWebSock():
    ws = websocket.WebSocket(sslopt={"cert_reqs": ssl.CERT_NONE})
    ws = create_connection(&#39;wss://<api>.execute-api.us-west-2.amazonaws.com/<stage>&#39;,
                           sslopt={"cert_reqs": ssl.CERT_NONE})
    ws.send("<some large msg>")

Exception : websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed. No err code as such

wscat :

wscat -c wss://<api>.execute-api.us-west-2.amazonaws.com/<stage>/ -w 5 -x <some large msg>

Silently exits

answered 3 years ago

Agreed on the size limit. The websocket limit is 128k while the gateway HTTP limit is 10MB? I can imagine developers walking away from websockets over this limit alone.

My websocket will require my clients to implement multi-page request logic, as a very small percentage of requests will go over 128k.

answered 2 years ago

If AWS increased the WebSocket frame size for just the initial frame it would make a huge difference.

That way the 1st frame could contain a large request from the client, with the response(s) going back as the request was processed.

answered 2 years ago

The frame limit size of 32KB is unreasonably low and makes writing ANYTHING except a simple text chat application nearly impossible. I don't understand how this is justifiable given that AWS lambda has a payload size of 256KB, eight TIMES the size.

We are seriously considering dropping API gateway completely if this isn't resolved soon.

answered a year 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.

Guidelines for Answering Questions