http-proxy-middleware icon indicating copy to clipboard operation
http-proxy-middleware copied to clipboard

ETIMEDOUT on macos

Open tinystorm opened this issue 3 years ago • 8 comments

Checks

Describe the bug (be clear and concise)

About half of the http and ws requests can not be proxy with such message ' Error occurred while trying to proxy request xxx from xxx to xxx (ETIMEDOUT) '

Yet my workmates using windows did not have such problem.

And Weirdly, When I using LAN and add headers: { 'Connection': 'keep-alive' } in config options,The problem gone! When I using WIFI or remove the headers config, Problem returns. It likes that http-proxy-middleware does not add headers when proxy the request

Step-by-step reproduction instructions

1. Using Macos 12.2.1 and Node 16.6.2
2. Proxy the http request and ws request in any project

Expected behavior (be clear and concise)

All the http and ws requests should be proxy successfully.

How is http-proxy-middleware used in your project?

meng@wangmengdeMacBook-Pro frontend % npm ls http-proxy-miidleware
[email protected] /Users/meng/IdeaProjects/manager/frontend
└── (empty)

What http-proxy-middleware configuration are you using?

module.exports = function (app) {
  app.use(createProxyMiddleware('/stomp', {
    target: backendAddr,
    ws: true,
    onProxyReqWs: (proxyReq, req, socket) => {
      socket.on('error', function (error) {
        console.warn('Websockets error.', error)
      })
    }
  }))
  app.use(createProxyMiddleware(['/api', '/pub'], {
    target: backendAddr,
    changeOrigin: true,
  }))
}

What OS/version and node/version are you seeing the problem?

System:
    OS: macOS 12.2.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 2.30 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.6.2 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 7.20.3 - /usr/local/bin/npm
  Managers:
    Gradle: 7.0.1 - /usr/local/bin/gradle
    Homebrew: 3.1.7 - /usr/local/bin/brew
    pip3: 19.2.3 - /usr/bin/pip3
    RubyGems: 3.0.3.1 - /usr/bin/gem
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 4.2.1 - /usr/bin/gcc
    Git: 2.24.3 - /usr/bin/git
    Clang: 12.0.0 - /usr/bin/clang
  Servers:
    Apache: 2.4.51 - /usr/sbin/apachectl
  IDEs:
    Nano: 2.0.6 - /usr/bin/nano
    Vim: 8.2 - /usr/bin/vim
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Java: 11.0.11 - /usr/bin/javac
    Perl: 5.30.3 - /usr/bin/perl
    Python: 2.7.18 - /usr/bin/python
    Python3: 3.8.2 - /usr/bin/python3
    Ruby: 2.6.8 - /usr/bin/ruby
  Databases:
    SQLite: 3.36.0 - /usr/bin/sqlite3
  Browsers:
    Chrome: 98.0.4758.80
    Safari: 15.3

Additional context (optional)

No response

tinystorm avatar Feb 14 '22 03:02 tinystorm

And I try to sniffer http packets from my node-server-ip to real-server-ip. According the packets, the request that proxy by http-proxy-middleware connection header is closed.

无标题

tinystorm avatar Feb 14 '22 07:02 tinystorm

Could you try on a different Mac?

chimurai avatar Feb 19 '22 15:02 chimurai

Same problem. I searched the 'etimedout in mac' in node.js issues and got some similar problems. I wonder if it is node.js's problem?

tinystorm avatar Feb 22 '22 07:02 tinystorm

You could try it with different node versions to see if that's the case

chimurai avatar Feb 22 '22 07:02 chimurai

Same problem. It is solved by switching only to mobile hotspot. But through wifi I often get timeout error. Using [email protected] in webpack-dev-server

samelm avatar Jul 12 '22 10:07 samelm

+1

cander0815 avatar Jul 15 '22 03:07 cander0815

Not helped. I am so troubled with it . Even in vite, I got same issue.

tinystorm avatar Jul 21 '22 09:07 tinystorm

@TinyStorm > Not helped. I am so troubled with it . Even in vite, I got same issue.

not to proxy socket.io, then replace the https: true with ca files , would improve this problem

rayzang8 avatar Mar 20 '23 05:03 rayzang8