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

Proxy sometimes hangs when request is disrupted #25

Open
noahgrant opened this issue Dec 11, 2014 · 10 comments
Open

Proxy sometimes hangs when request is disrupted #25

noahgrant opened this issue Dec 11, 2014 · 10 comments

Comments

@noahgrant
Copy link
Contributor

We have a single-page-app with several proxies as we migrate off of rails, and we've found that sometimes, when a request hasn't completed (whether it's a proxied request or not, i think) and we make a new request (either by refreshing the page or, say, clicking another part of the page and triggering a new request), the proxy hangs, and we have to restart our server. On a refresh, we see all locally served files, but requests to a proxied server hang without a response. We're running proxy-middleware within browsersync, all within gulp.

If you have any insights about why this might happen, I'm happy to take a look and give a crack at it, but I figured I should post an issue about it to get some feedback first.

Thanks!

@andrewrk
Copy link
Collaborator

I have not used this module in a while; it's pretty much a community-maintained project at this point. So you'll have to investigate this. Luckily the source is still pretty small so you shouldn't have too hard of a time with it.

@RobbinHabermehl
Copy link

I've noticed the same behavior using v0.5.0 and as well on v.0.9.0. Unfortunately I haven't been able yet to figure out the cause; so far it seems to occur at random.

@noahgrant
Copy link
Contributor Author

@RobbinHabermehl what does the rest of your stack look like? Last week I tried to debug by putting a lot of request/response event hooks in the proxy, but nothing seemed very out of the ordinary when it would hang. I'm thinking it's actually a browsersync issue—are you using browsersync?

@RobbinHabermehl
Copy link

@noahgrant; I'm not using browser-sync, nor something similar. Originally version 2.14.x was being used, but I've reproduced the issue with version 3.3.x as well.

@dshefchik
Copy link

+1 to this. I'm using a 60-second long-polling interval from the client code to connect-proxy, and then to the backend. When I'm in rapid development and reloading often, these requests seem to get 'stuck' in the queue. No further requests are proxied until the one that's stuck is returned. I have to kill and restart the proxy server

@noahgrant
Copy link
Contributor Author

@dshefchik what's your stack look like?

@dshefchik
Copy link

@noahgrant

proxy-middleware: 0.5.1,
gulp-webserver: 0.9.0,
node: 0.10.28,
gulp: 3.8.11
OSX 10.10.2

@corentin-gautier
Copy link

+1

@mur-dog
Copy link

mur-dog commented Feb 27, 2015

I have also run into hanging issues with the proxy until restart - using Ionic Framework and livereload. It would consistently fail after 5 reloads - For my case what is happening is that after 5 tries the http_agent_maxsockets limit is kicking in and further attempts block. Have yet to be able to trackdown the root cause of why the http keep-alive sockets are not getting reused/blocking.

As a quick workaround I turned off keep-alive connection-pooling and no longer have hang ups.

  var opts = url.parse(proxy.proxyUrl);

  //opt out of the pooling
  opts.agent = false;
  app.use('/path/', proxy(opts));

@noahgrant
Copy link
Contributor Author

thanks @mur-dog. I'm not sure setting opts.agent to false works for me, because the options headers get set to the request headers, so the request is sent with both agent: false as well as connection: keep-alive (the default connection header). For me, that made the response headers have connection: keep-alive. setting, in your example:

opts = url.parse(proxy.proxyUrl);
opts.headers = {
   connection: 'close'
};

made the response headers give a connection: close. This might hopefully be a workaround, but still doesn't solve the hanging issue :-/

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

6 participants