【发布时间】:2021-06-12 18:54:49
【问题描述】:
我在 ASP.net 上构建了一个客户端应用程序,并以 Nodejs 和 express 为后盾,托管在 IIS 版本 10 的 Windows Server 2016 上。 当我将请求正文中包含大量数据的发布请求发送到 API 端点时,它会在 2 分钟后在浏览器控制台中返回 net::ERR_CONNECTION_RESET 错误。这早些时候工作正常,突然它开始给出这个错误。 当我在请求正文中传递小数据时它工作正常,但是当它超过 320 时,它没有达到终点并在 2 分钟后在控制台 net::ERR_CONNECTION_RESET 上给出错误消息。
- 传入请求正文的数据
[{ProductId: "352561", Country: "United State"}, {ProductId: "364321", Country: "China"}]
[0 … 99]
[100 … 199]
[200 … 299]
[300 … 302]
- 我从其中向 api 端点发出请求的 Aspx 页面
makePostRequest('http://localhost:3000/searchMultiple', tableData);
async function makePostRequest(path, tableData) {
const result = await fetch(path, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(tableData)
});
//console.log(result);
const data = await result.json();
}
- 节点 API 端点
app.post('/searchMultiple', (request, response) => {
tableData = request.body;
if (tableData.length > 0) {
searchMultipleProduct(tableData)
.then(results => {
//Returns a 200 Status OK with Results JSON back to the client.
response.status(200);
response.json(results);
});
} else {
response.end();
}
});
- 服务器端 web 配置文件 IISNode
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="nodejs">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" ignoreCase="true" negate="true" />
</conditions>
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295" />
<hiddenSegments>
<add segment="node_modules" />
<add segment="iisnode" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
- 客户端网络配置文件
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
</controls>
</pages>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647" />
</webServices>
</scripting>
</system.web.extensions>
</configuration>
任何帮助/指针/链接/任何东西都将不胜感激。
【问题讨论】:
标签: node.js asp.net express iisnode