Last active
November 21, 2016 17:52
-
-
Save lpinca/494eff98deeef1531b734a38c0f6fe46 to your computer and use it in GitHub Desktop.
InvalidStateError: SockJS has already been closed
This file contains 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="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> |
This file contains 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
'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