Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Express 3.0.1 #326

Closed
sirganya opened this issue Nov 2, 2012 · 5 comments
Closed

Express 3.0.1 #326

sirganya opened this issue Nov 2, 2012 · 5 comments

Comments

@sirganya
Copy link

sirganya commented Nov 2, 2012

Hi,

When I use Express with RoutingProxy I get

proxy.error: Error: socket hang up

using node 0.8.2.

I've been at it for a few hours and was wondering if the problem is with connect and express and if it was workable or if I should just downgrade the packages.

Sorry for the vagueness. I can post more details if someone thinks it's worthwhile.

Thanks

@mmalecki
Copy link
Contributor

Need more details and code. This error means that backend server didn't respond in timely fashion or that connection was closed forcefully.

@sirganya
Copy link
Author

I should have replied to myself, it turned out to be the issue covered here previously with express doing non standard things to the body. After a lot of hair pulling I've decided to abandon http-proxy. It seems that I'm going to run into problems combining express with nodejitsu software. I've spent a few days debating wether to move to flatiron but it seems that express is favored so I've bet the house on that. I like that flatiron seems to be closer to the ideals of node but I've been swayed by the very few comparisons I can find online. If anyone here would like to throw their two cents in favor of flatiron I'd be very happy to hear them. I think the nodejitsu stuff is super solid but time is against me to allow me to learn and move to flatiron.

@indexzero
Copy link
Contributor

@sirganya Thousands of express based apps run on nodejitsu which uses this library to proxy. There is no incompatibility between express and http-proxy

@sirganya
Copy link
Author

sirganya commented May 7, 2013

I'm back with this issue again....
express@2.5.11
formidable@1.0.14
http-proxy@0.10.2
node v0.10.5

It proxies everything correctly except a POST with a body.

app.all('/ads*', function(req, res, next) {

    var buffer = httpProxy.buffer(req);

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

});

Formidable then gives this error.

Error: Request aborted
   at IncomingMessage.IncomingForm.parse (/git/sdl/node_modules/formidable/lib/incoming_form.js:107:19)
   at IncomingMessage.EventEmitter.emit (events.js:90:17)
   at abortIncoming (http.js:1661:11)
   at Socket.serverSocketCloseListener (http.js:1672:5)
   at Socket.EventEmitter.emit (events.js:123:20)
   at Socket._destroy.destroyed (net.js:357:10)
   at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Here's the code from incoming_form.js lines 99 - 124

// Start listening for data.
  var self = this;
  req
    .on('error', function(err) {
      self._error(err);
    })
    .on('aborted', function() {
      self.emit('aborted');
      self._error(new Error('Request aborted'));
    })
    .on('data', function(buffer) {
      self.write(buffer);
    })
    .on('end', function() {
      if (self.error) {
        return;
      }

      var err = self._parser.end();
      if (err) {
        self._error(err);
      }
    });

  return this;
};

I had used connect-restreamer to fix it before, but it looks like it's not the issue anymore.

https://github.com/dominictarr/connect-restreamer

@sirganya
Copy link
Author

sirganya commented May 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants