Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services API网关返回具有特定文件大小的502错误_Amazon Web Services_Amazon S3_Aws Api Gateway - Fatal编程技术网

Amazon web services API网关返回具有特定文件大小的502错误

Amazon web services API网关返回具有特定文件大小的502错误,amazon-web-services,amazon-s3,aws-api-gateway,Amazon Web Services,Amazon S3,Aws Api Gateway,我们正在使用S3和AmazonAPI网关。在AWS中测试API时出现502个错误。在我的本地机器上,我总是按预期获得文件 我创建了以下TestApiController,我从UI发出了一个简单的HTTP GET请求: [HttpGet("file/{type}")] public IActionResult GetFile(string type) { var filePath = _env.ContentRootPath + "/Files/my-sm

我们正在使用S3和AmazonAPI网关。在AWS中测试API时出现502个错误。在我的本地机器上,我总是按预期获得文件

我创建了以下
TestApiController
,我从UI发出了一个简单的HTTP GET请求:

    [HttpGet("file/{type}")]
    public IActionResult GetFile(string type)
    {
        var filePath =  _env.ContentRootPath + "/Files/my-small.fileType"; // ~5.5MB

        if (type == "big"){
            filePath = _env.ContentRootPath + "/Files/my-big.fileType";// ~6.6MB
        }else if(type == "slowbig") {
            Thread.Sleep(11000);
            filePath = _env.ContentRootPath + "/Files/my-big.fileType";
        }

        var xml = System.IO.File.ReadAllText(filePath);

        return File(Encoding.ASCII.GetBytes(xml), "text/xml", "hardcodedoutput.fileType");
    }
在测试服务器AWS环境中

如果
type==big或type==slowbig

错误:HTTP 502。响应:
{“消息”:“内部服务器错误”}

否则

HTTP 200。我按预期在浏览器中下载了文件
hardcodedoutput.fileType

在本地开发机器上运行API时:

如果
type==big或type==slowbig或type==small

HTTP 200。我按预期在浏览器中下载了文件
hardcodedoutput.fileType


502可以指示超时问题。服务器占用的时间比预期的长。检查http服务器日志中的错误。如果没有,请增加网关上的超时

根据

AWS Lambda限值

以下限制适用于功能配置、部署和部署 执行。它们无法改变

(请求和答复)

6MB(同步)

256 KB(异步)

这些数据(尽管是一个神秘的错误)与我的经验完美吻合。>6MB的文件不起作用