Hi All, AWS API Gateway has a max payload limit o...
# help
Hi All, AWS API Gateway has a max payload limit of 10MB for Http APIs, but only 128 kB for Websocket APIs. I’m trying to paginate results from my API, but I need to know the payload limit from within my Lambda function? Is there any way to tell whether it is running in deploy mode (HTTP API) or in debug (WS API) mode ? Thanks! https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html#apigateway-execution-service-websocket-limits-table
If you return a large response in debug mode, your local server will upload the contents to s3 and not send the whole data over socket
and the stub lambda will download it and return
So you shouldn't be running into these limits
good to know, but wasn’t working for me; my (local server) lambda logs showed that it was throwing max payload http error codes.
@thdxr wow, that's smart!
All Frank's idea, I was just the one who complained about it 😄
@Guy Shechter are you on latest SST?
can you share the error you're getting
I have some endpoints that return a large payload and it's working for me
I don’t think this question is anything to do with SST - more about having one lambda that can service both websocket and HTTP calls
What I’ve done in the past is to have two functions, both of which delegate to a function that has a common interface. That seemed to be the cleanest way of separating concerns for me
That was my initial interpretation of the question but the part about being able to tell if it's running in deploy vs debug mode made me think it was related to SST
Ah yeah true - just re-reading that now
Could also be that the max payload errors were from the external websocket API, not SST’s internal one - @Guy Shechter?
Copy code
Traceback (most recent call last):
  File "node_modules/@serverless-stack/cli/scripts/util/bootstrap.py", line 99, in <module>
    r = request.urlopen(req, data=data)
  File "python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 413: Payload Too Large
If I size my response so that it’s ~< 90k, it works no problem. If I increase to e.g. 190k, I get the above error
You’re sending the request to the lambda over websocket or HTTP?
Ah I think this is a different issue from inside the dummy AWS Runtime server in sst, one second
Yeah found the issue, going to figure out a fix
@Guy Shechter do you mind if I publish a canary release so you can try it to see if it fixes your issues?
Can you try
@serverless-stack/cli@0.40.1-next.0+ba2c56e @serverless-stack/resources@0.40.1-next.0+ba2c56e
Hey @Guy Shechter pinging in case you didn't see
@thdxr I didn’t see. Will check later today. Thanks!
The limit increase is released now
Sorry didn’t have time yet to verify. But I will!