开发团队正在运行相同的代码,他们使用 UNIX 机器,我使用 MAC。 我们有一个 Maven 项目 API 与前端 Angular 分离。 Angular 在开发模式下对 API 进行代理调用。
我收到 ECONNRESET 错误,并且无法保存或加载某些结果。相当随意,因为大多数都可以解决。
我通过使用 * 或使用 IP 而不是本地主机名称等尝试了迄今为止人们在代理设置上建议的所有技巧。其中三个必须与 MAC 操作系统相关。这是 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对象
关于node.js - 为什么我只在 MAC OSX 中的代理调用上不断收到 ECONNRESET 错误,完全任意的一些成功的调用(非常绝望),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54096937/