When i use the vite (bottom layer is node-http-proxy) to start a http-server and proxy the request to target server, ETIMEDOUT problem occurs frequently.

未关闭
#1,622 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞

调研方向

从报告中的 Vite 代理配置以及对 /stomp 和 /api 的请求开始,然后跟踪 node-http-proxy 如何打开目标连接,以及它如何在 macOS 和 Windows 上处理 ETIMEDOUT。在报告中的 HDD 和较慢网络条件下复现该行为;完成标准是确定一个可靠的原因,并记录或测试由此产生的行为。

由索引模型根据 Issue 内容生成。

描述

In vite, I was trying to start a http server with following code

server: {
    open: true,
    proxy: setupProxy()
  }

const setupProxy = () => {
  const backendAddr = 'http://192.168.50.213:8180/'

  const wsOptions = {
    target: backendAddr,
    ws: true
  }
  const httpOptions = {
    target: backendAddr,
    changeOrigin: true
  }
  return {
    '/stomp': wsOptions,
    '/api': httpOptions,
    '/pub': httpOptions,
    '/docs': httpOptions
  }
}

According to the vite document, Its bottom layer uses node-http-proxy.
My problem is that my target server is sure to be accessible, but it will encounter proxy timeout problems from time to time.

Error: connect ETIMEDOUT 192.168.50.213:8180
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1300:16)
3:23:48 PM [vite] http proxy error at /stomp/info?t=1670657002883:
Error: connect ETIMEDOUT 192.168.50.213:8180
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1300:16)
3:23:48 PM [vite] http proxy error at /stomp/info?t=1670657002882:
Error: connect ETIMEDOUT 192.168.50.213:8180
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1300:16)
3:23:48 PM [vite] http proxy error at /api/settings/hiddenMenuPaths:
Error: connect ETIMEDOUT 192.168.50.213:8180

What I can offer is that this problem will not occur when my target server deploys on a ssd, which is, the access speed is very fast.
When I deploy the server on a hdd or when the network environment is more complicated, which is, the access speed is not so fast, but definitely not slow, problem returns.
All my colleagues who use Mac have this problem, but all my colleagues who use Windows don't.
Based on the above phenomenon, I doubt whether there are some special configurations for the mac version of nodejs, such as the default timeout time, fault tolerance or automatic retry mechanism, which causes frequent timeout problems when the target server apis are slightly slower.

主要语言
JavaScript
星标
14.1k
派生
2k
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

http-party/node-http-proxy 的其他 Issue

查看 http-party/node-http-proxy 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。