【问题标题】:Error with large file uploads - The specified CGI application encountered an error and the server terminated the process上传大文件时出错 - 指定的 CGI 应用程序遇到错误,服务器终止了进程
【发布时间】:2019-11-04 13:44:25
【问题描述】:

我们正在通过 ASP.net 应用程序中的 REST 请求将 shapefile zip 上传到 GeoServer。小的 .zip 文件 (~2MB) 可以正常工作,但任何比这更大的文件(我们有一个 ~70MB 的 .zip)都不会。 WebRequest.GetResponse() 返回 502 Bad Gateway,读取响应流提供此错误:

“指定的 CGI 应用程序遇到错误,服务器终止了进程。”

这是创建请求并获取响应的代码:

WebRequest request = WebRequest.Create(URL);

request.ContentType = "application/xml";
request.Method = "PUT";
request.Credentials = new NetworkCredential(username, pswd);

Stream requestStream = request.GetRequestStream();
requestStream.Write(contentBytes, 0, contentBytes.Length);
requestStream.Close();

WebResponse response = request.GetResponse();

REST 调用是到/workspaces/{workspaceName}/datastores/{storeName}/{method}.{format},它将文件上传到指定的数据存储,如果不存在则创建它。

contentBytes 是从上传的 HttpPostedFile zip 中的 MemoryStream 创建的字节[]。

就像我说的,适用于较小的拉链。谷歌搜索错误似乎表明它来自 Azure 或 IIS,但是,似乎没有一个解决方案适合我们的情况 (altering the web.config in ways that don't apply to our application or don't work),因为它不是 .net Core 应用程序。

This 问题似乎有类似的问题,但收到不同的错误消息。增加超时在 C# 或 web.config 中均无效。

shapefile 本身似乎没有任何问题,其他 shapefile 查看器能够处理这些 shapefile。

【问题讨论】:

    标签: c# asp.net azure geoserver


    【解决方案1】:

    我们的最佳猜测最终是我们在某处达到了 REST 请求的某种正文大小限制,并且没有收到有用的错误消息或在 GeoServer 日志中收到任何错误消息。简而言之,我们最终做的是从通过 GeoServer REST API 上传文件(简单而干净)切换到通过 FTP 手动上传,然后在 REST 请求中使用新上传文件的 URL(混乱和复杂):

    1. 在我们的 C# 代码中,我们将 FTP request(从 Azure 获取我们的 FTP 凭据)创建到新文件的“数据”文件夹中的 create a directory。这是我们通过 REST 上传文件时导入器放置文件的位置。

    2. Make FTP requests for each file in the .zip, uploading them to the new directory.

    3. 最后,make a REST call to import the layer,(使用 /workspaces/{workspaceName}/datastores/{storeName}/{method}.{format}),而不是在正文中发送文件,而是发送的 URL已上传的 .shp 文件。

    4. 如果任何步骤失败,rollback and delete the files in the FTP directory and then delete the directory

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-17
      • 2022-12-11
      • 1970-01-01
      • 1970-01-01
      • 2018-12-24
      • 1970-01-01
      相关资源
      最近更新 更多