peerjs with ssl, express, https

358 views
Skip to first unread message

Aishwarya Chaturvedi

unread,
Jul 7, 2017, 4:38:31 AM7/7/17
to PeerJS
I am writing an app using https, express and peerjs ssl, below i have mentioned the code

const express = require('express')
const app = express()
const https = require('https')
const path = require('path')
const fs = require('fs')
const ExpressPeerServer = require('peer').ExpressPeerServer

const options = {
  key: fs.readFileSync('/etc/apache2/ssl/apache.key'),
  cert: fs.readFileSync('/etc/apache2/ssl/apache.crt')
}

const server = https.createServer(options, app)

const io = require('socket.io')(server)

var PeerServer = require('peer').PeerServer({port: 8000,
proxied: true,
  ssl: {key: fs.readFileSync('/etc/apache2/ssl/apache.key'),
  certificate: fs.readFileSync('/etc/apache2/ssl/apache.crt')}},
() => {
console.log('running peerserver')
})
//
app.use('/peerjs', PeerServer)

app.use(express.static(path.join(__dirname, 'public')))

server.listen(3000, (req, res) => {
  console.log('listening on port 3000')
})

app.get('/', (req, res) => {
  res.sendFile(path.join(__dirname, 'public/index.html'))
})

below is client side code

const peerObj = {
  host: '0.0.0.0',
  port: 9000,
  path: '/peerjs',
  debug: 3,
  config: {icerServers: [
    { url: 'stun:stun1.l.google.com:19302' },
    { url: 'turn:numb.viagenie.ca',
      credential: 'muazkh',
      username: 'web...@live.com' }
  ]}
}
peer = new Peer(peerObj)



 After this when I run my app, it give me this error



GET https://0.0.0.0:3000/peerjs/peerjs/id?ts=14994123658290.8549044374474446 net::ERR_INSECURE_RESPONSE PeerJS: ERROR Error retrieving ID undefined

Can anybody help on this

Jerami Johnson

unread,
Nov 14, 2017, 1:55:08 AM11/14/17
to PeerJS
It looks like your port number on client side specifies the wrong port. Try port 8000 the same as the port that is listening on your peerjs server.
Reply all
Reply to author
Forward
0 new messages