Created
July 31, 2019 06:08
-
-
Save memandip/12cd1b95b37b8379ace3c1a977bb126a to your computer and use it in GitHub Desktop.
Socket.io https websocket server with custom web socket url
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
const fs = require('fs') | |
const https = require('https') | |
const app = require('express')() | |
var privateKey = fs.readFileSync('./privatekey.pem', 'utf8') | |
var certificate = fs.readFileSync('./certificate.pem', 'utf8') | |
const credentials = {key: privateKey, cert: certificate} | |
const httpsServer = https.createServer(credentials, app) | |
// const server = require('http').createServer(app) | |
const io = require('socket.io')(httpsServer, {path:'/web/socket'}) | |
io.on('connection', client => { | |
console.log('client conneted') | |
client.on('disconnect', () => console.log('client disconnected')) | |
}) | |
httpsServer.listen(8081, () => 'https server listening on port 8081') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment