Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Small repro of TCP keep alive flood
environment:
node for Windows v.0.6.8
socket.io v. 0.9.6
http-proxy v. 0.8.0
browser: chrome (this will force the use of websockets)
test:
- 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 socket.io, no TCP keep alives are used when going through http-proxy, including when the server is on Windows.
<html>
<head>
<title>socket.io client</title>
<script src="/socket.io/socket.io.js"></script>
<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) {
console.log(data);
});
</script>
</head>
<body>
</body>
</html>
var socketio = require( 'socket.io'), 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) {
response.end(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.