Skip to content

Instantly share code, notes, and snippets.

@brettkiefer
Created March 15, 2011 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettkiefer/871365 to your computer and use it in GitHub Desktop.
Save brettkiefer/871365 to your computer and use it in GitHub Desktop.
Running this causes an ssl hang within a few hard reloads.
// Assumes a privatekey.pem and certificate.pem in this directory
// Probably have to run as root to start on port 443
// See http://www.silassewell.com/blog/2010/06/03/node-js-https-ssl-server-example/ for ssl cert setup
var https = require('https');
var fs = require('fs');
var url = require('url');
var sslOpts = {
key: fs.readFileSync(__dirname + '/privatekey.pem'),
cert: fs.readFileSync(__dirname + '/certificate.pem')
}
var size = 100000;
var bs = new Array(size);
for (var i = 0; i < size; i++) bs[i] = 'b';
var bigstr = bs.join('');
var server = https.createServer(sslOpts, function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('' +
'<!doctype html>' +
'<html>' +
'<head>' +
'<title>ssl hanger</title>' +
'<script src="/one"></script>' +
'<script src="/two"></script>' +
'<script src="/three"></script>' +
'<script src="/four"></script>' +
'<script src="/five"></script>' +
'<script src="/six"></script>' +
'</head>' +
'<body>' +
'<h1>Just keep hard-refreshing the page (ctrl-shift-r) and waiting for the page load. Eventually a page will hang.</h1>' +
'<span>A bunch of data to make the request bigger and make the hang happen faster -> ' + bigstr + '</span>' +
'</body>' +
'</html>'
);
});
server.listen(443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment