node.js - 为什么我只在 MAC OSX 中的代理调用上不断收到 ECONNRESET 错误,对于一些成功的调用完全是任意的(非常绝望)
问题描述
开发团队正在运行相同的代码,他们使用 UNIX 机器,我使用 MAC。我们有一个 Maven 项目 API 与前端 Angular 分离。Angular 在开发模式下对 API 进行代理调用。
我收到 ECONNRESET 错误,无法保存或加载某些结果。相当随意,因为它们中的大多数都可以解决。
到目前为止,我尝试了人们在代理设置上建议的所有技巧,方法是使用 * 或使用 IP 而不是 localhost 名称等。其中三个必须与 MAC OS 相关。这是proxy.config中的代理设置代码
{
"/emport-api/*": {
"target": "http://localhost:8080",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
这是 package.json 中的部分
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --proxy-config proxy.conf.json --extract-css=true",
"build": "ng build --prod --progress export.modal.component.ts --output-path dist",
"test": "jest",
"codecoverage": "jest --coverage",
"test:watch": "jest --watch",
"lint": "ng lint",
"fixlinting": "ng lint --fix",
"e2e": "ng e2e"
},
这是错误之一
[HPM] GET /emport-api/rest/user/accessControl -> http://localhost:8080
[HPM] Error occurred while trying to proxy request /emport-api/rest/user/accessControl from localhost:4200 to http://localhost:8080 (ECONNRESET)
如果我需要在此处放置某些信息以便更好地解释问题,请让我现在。
解决方案
在尝试了所有其他方法(包括给出超时持续时间)后找到了解决此问题的方法,只有保持连接活动选项为我解决了这个问题。
添加
"headers": {
"Connection": "keep-alive"
}
到 api 对象
推荐阅读
- c - 在给定的代码行中递归是如何发生的?
- python - 如何从测试中获取通过库请求(python)执行的所有 api 方法?
- amazon-web-services - 如何在 fluentd tail/s3 插件中删除 unicode
- c++ - 在 C++ 中创建具有键和值形式的 JSON 字符串
- python - 如何使用高级异步 API 彻底终止子进程?
- c++ - 将空字符串引号(例如“”)作为值传递给未注册的 boost::program_options
- javascript - 如何使用嵌套循环访问一维数组中的元素?
- ios - 无法在 iOS 应用程序的本机模块中触发框架中的委托方法
- java - 即使在退出活动或关闭应用程序后也保存文本颜色
- ios - 我在 Xcode 中有一个 png 作为按钮,但单击 png 的空白部分不会触发该按钮。我该如何克服呢?