Created
March 25, 2014 11:47
-
-
Save lpinca/9760159 to your computer and use it in GitHub Desktop.
Test case for SockJS retransmission timeout issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sock = new SockJS('/test', null, { | |
protocols_whitelist: ['jsonp-polling'] | |
}); | |
sock.onopen = function () { | |
console.log('open'); | |
}; | |
sock.onerror = function (err) { | |
console.log(err); | |
}; | |
sock.onmessage = function (e) { | |
console.log(e.data); | |
}; | |
sock.onclose = function (e) { | |
console.log('close'); | |
console.log(e); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<script src="http://cdn.sockjs.org/sockjs-0.3.4.js"></script> | |
<script src="/client.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "rto", | |
"version": "0.0.0", | |
"description": "RTO lowerbound is too low for `jsonp-polling`", | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"license": "MIT", | |
"dependencies": { | |
"sockjs": "^0.3.8" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
, http = require('http'); | |
var server = http.createServer(function (req, res) { | |
if (req.url === '/client.js') { | |
res.setHeader('Content-Type', 'application/javascript'); | |
fs.createReadStream(__dirname + '/client.js').pipe(res); | |
return; | |
} | |
res.setHeader('Content-Type', 'text/html'); | |
fs.createReadStream(__dirname + '/index.html').pipe(res); | |
}); | |
var sock = require('sockjs').createServer(); | |
sock.on('connection', function (socket) { | |
socket.write('bar'); | |
}); | |
sock.installHandlers(server, { prefix: '/test' }); | |
server.listen(3000, function () { | |
console.log('listening on localhost:3000'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment