Last active
December 18, 2015 05:28
-
-
Save m1sta/5732497 to your computer and use it in GitHub Desktop.
Simple socket.io with https connection that endlessly connect/disconnect/connect loops
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 xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title></title> | |
<script type="text/javascript" src="/socket.io/socket.io.js"></script> | |
<script> | |
var socket = io.connect(); | |
</script> | |
</head> | |
<body> | |
Done. | |
</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": "test", | |
"version": "0.0.1", | |
"private": true, | |
"dependencies": { | |
"redis": "~0.8.3", | |
"socket.io": "~0.9.16", | |
"request": "~2.21.0", | |
"express": "~3.2.6", | |
"cookie": "~0.1.0", | |
"connect-redis": "~1.4.5" | |
}, | |
"scripts": { | |
"start": "test.js" | |
} | |
} |
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 express = require('express'); | |
var fs = require('fs'); | |
var http = require('http') | |
var https = require('https') | |
var io = require('socket.io') | |
var port = process.env.port || 443; | |
var sslOptions = { | |
key: fs.readFileSync('./ssl/app-key.pem').toString(), | |
cert: fs.readFileSync('./ssl/app-cert.pem').toString(), | |
ca: [fs.readFileSync('./ssl/ca2-cert.pem').toString(), | |
fs.readFileSync('./ssl/ca1-cert.pem').toString()] | |
}; | |
var app = express(); | |
var server = https.createServer(sslOptions, app); | |
io = io.listen(server, sslOptions); | |
app.use(express.static('./public')); | |
server.listen(port, function () { }); | |
io.sockets.on('connection', function (socket) { console.log("Yep") }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment