node-http-proxy
node-http-proxy copied to clipboard
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.
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.