Skip to content

Instantly share code, notes, and snippets.

@lpinca
Last active November 21, 2016 17:52
Show Gist options
  • Save lpinca/494eff98deeef1531b734a38c0f6fe46 to your computer and use it in GitHub Desktop.
Save lpinca/494eff98deeef1531b734a38c0f6fe46 to your computer and use it in GitHub Desktop.
InvalidStateError: SockJS has already been closed
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="https://cdn.jsdelivr.net/sockjs/1.1.1/sockjs.min.js"></script>
<script>
(function () {
var sockjs = new SockJS('/foo');
setTimeout(function () {
sockjs.close();
}, 25);
})();
</script>
</body>
</html>
'use strict';
const sockjs = require('sockjs');
const http = require('http');
const path = require('path');
const fs = require('fs');
const server = http.createServer((req, res) => {
res.setHeader('Content-Type', 'text/html');
fs.createReadStream(path.join(__dirname, 'index.html')).pipe(res);
});
const service = sockjs.createServer({
sockjs_url: 'https://cdn.jsdelivr.net/sockjs/1.1.1/sockjs.min.js'
});
service.installHandlers(server, { prefix: '/foo' });
server.listen(3000, () => console.log('listening on *:3000'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment