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

ECONNRESET

Open ronag opened this issue 9 years ago • 3 comments
trafficstars

I don't understand why I keep getting ECONNRESET with this rather simple proxy:

import httpProxy from 'http-proxy'
import http from 'http'

const proxy = httpProxy.createProxyServer({})

const server = http.createServer((req, res) => {
  console.log(req.url)
  if (req.url.startsWith('/media') || req.url.startsWith('/scene')) {
    proxy.web(req, res, { target: 'http://127.0.0.1:8001' }, err => {
      if (err) {
        console.error(err)
      }
    })
  } else if (req.url.startsWith('/authenticate')) {
    proxy.web(req, res, { target: 'http://127.0.0.1:4223' }, err => {
      if (err) {
        console.error(err)
      }
    })
  } else {
    proxy.web(req, res, { target: 'http://127.0.0.1:9966' }, err => {
      if (err) {
        console.error(err)
      }
    })
  }
})

http.globalAgent.maxSockets = Infinity
server.timeout = 3 * 60 * 60 * 1000 // 3 hours
server.listen(8080)

Not going through the proxy works perfectly.

node-proxy: 1.13.2 node: 5.5.0

ronag avatar Mar 07 '16 18:03 ronag