Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Small repro of TCP keep alive flood
node for Windows v.0.6.8 v. 0.9.6
http-proxy v. 0.8.0
browser: chrome (this will force the use of websockets)
- run server: node server
- load client into chrome using http://host:8080/client.html
- observe in wireshark a flood of TCP keep alives
- bypass http-proxy by setting the port in client.html to 8081, reload client
- observe no TCP keep alives in wireshark
When the server is run on Mac, no TCP keep alives are noticed, even when going through http-proxy.
The problem is specific to websockets. When long-poll transport is forced in, no TCP keep alives are used when going through http-proxy, including when the server is on Windows.
<title> client</title>
<script src="/"></script>
var port = 8080;
//var port = 8081;
var socketioUrl = 'http://' + window.location.hostname + ':' + port;
console.log( 'socketioUrl: ' + socketioUrl);
var socket = io.connect( socketioUrl);
socket.on('hello', function (data) {
var socketio = require( ''), httpProxy = require('http-proxy'), http = require('http'),
fs = require('fs');
var httpServer = http.createServer( function( request, response) {
if( request.url === '/client.html') {
fs.readFile('client.html', function(err, data) {
}).listen( 8081);
var io = socketio.listen( httpServer);
io.sockets.on( 'connection', function( socket) {
console.log( 'connection');
socket.on( 'disconnect', function() {
console.log( 'disconnect')
socket.emit( 'hello', 'hello world');
var proxy = new httpProxy.RoutingProxy();
proxyHttpServer = http.createServer( function(request, response) {
console.log('forwarding ' + request.url);
proxy.proxyRequest(request, response, {host: 'localhost', port: 8081});
proxyHttpServer.on('upgrade', function(request, socket, head) {
console.log('upgrade ' + request.url);
proxy.proxyWebSocketRequest(request, socket, head, {host: 'localhost', port: 8081});
proxyHttpServer.listen( 8080);
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.