Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Flood of TCP keep-alives when proxying websocket #237

jkorycki opened this Issue · 6 comments

3 participants


Setup: client in chrome browser connects to http-proxy which forwards to server. The connection is setup using websocket, and functionally everything works well. http-proxy version 0.8.0, version 0.9.6, node version 0.6.8.

Problem: http-proxy sends a flood of TCP keep-alives to the client, at a rate of about 30 per sec (!). This was confirmed using wireshark. In the test, the websocket connection is kept open but it is otherwise completely idle, we send no messages over it.

Attempted fix: proxyHttpServer.on('upgrade', function(request, socket, head) { socket.setKeepAlive( false); ...}. Unfortunately this has no effect, and the keep-alives keep on getting sent at high rate.


That doesn't sound good. I have a feeling this might be due to something specific in your environment.

Could you possibly post your logs or a minimal reproducible case of code we can run?



I created a very simple repro sample. Can you let me know where to post it?

Note: the issue occurs on Windows, using node.exe. It works fine on Unix (tested on Mac).


Just windows! Hrmm....I wonder if this could be a core issue.

Just post a link to the gist here.


Gist link:

This problem disappears when http-proxy is bypassed, i.e. client connects directly to I contacted also node developers at Microsoft, and got the following response:

"This sounds like a Windows-specific issue with http-proxy. By default, we don’t send keep-alive packets in node core. Most likely http-proxy enables keep-alive (using "


I did dome more digging. The problem is with setting the keepalive on a socket in proxyWebSocketRequest() in a helper function _socket(). On Windows this results in the keepalive flooding, on Mac no such issue. For the purposes of my application, which already has a heartbeat in layer, the fix is to reset the keepalive after proxyWebSocketRequest():

proxyHttpServer.on('upgrade', function(request, socket, head) {
logger.debug('upgrade ' + request.url);
proxy.proxyWebSocketRequest(request, socket, head, getRoutingTarget(request));
socket.setKeepAlive(false, 0);

I think this is something that can still be improved in http-proxy, maybe in the documentation, since someone else that makes use of http-proxy on Windows in conjunction with websocket will surely run into this problem again.


Any thoughts on this issue by anyone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.