Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Issues
  • #364
Closed
Open
Issue created Jan 10, 2013 by Administrator@rootContributor

"proxyError" event emitted twice

Created by: subnetmarco

I created a simple proxy server that tries to proxy the request to a non existent server. I've written this to return an error message when the final host is unreachable. After I make the request, when the proxyError is caught, I keep getting two times the same error:

{ [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect' }
{ [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect' }

I'm expecting the error to be thrown only once. This is the code I'm using:

var httpProxy = require('http-proxy');

var server = httpProxy.createServer(function (req, res, proxy) {
  var buffer = httpProxy.buffer(req);

  proxy.proxyRequest(req, res, {
    host: '127.0.0.1',
    port: 10000,
    buffer: buffer
  });

});

server.proxy.on('proxyError', function (err, req, res) {
    // This error is printed two times!
    console.log(err);
});

server.proxy.on('end', function() {
  console.log("The request was proxied.");
});

server.listen(9000);

Assuming that nothing is running on 127.0.0.1:10000, trying to execute:

curl http://127.0.0.1:9000

prints two times the same error message to the console.

I'm running:

  • node v0.8.17
  • node-http-proxy v0.8.7
Assignee
Assign to
Time tracking