0

Getting error of id undefined. If I use 0.peerjs.com it works just fine. This is the client side code :

var peer = new Peer({
        host: 'vchat247.hopto.org',
        port: 9000,
        path: '/peer/',
        debug: 3,
        config: {
            'iceServers': [
                {url: 'stun:stun1.l.google.com:19302'},
                {
                    url: 'turn:numb.viagenie.ca',
                    credential: 'muazkh', username: 'webrtc@live.com'
                }
            ]
        }
    });

And here is my own peer-server code :

var fs = require('fs');
var PeerServer = require('peer').PeerServer;

var server = PeerServer({
    port: 9000,
    path: '/peer/',
    ssl: {
        key: fs.readFileSync('./myserver.key'),
        certificate: fs.readFileSync('./vchat247.hopto.org.crt')
    }
});

This is what i get: enter image description here

What am I doing wrong?

And if I use this code :

function randomString(length, chars) {
        var result = '';
        for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
        return result;
    }
   var peer = new Peer(randomString(16, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), {host: 'vchat247.hopto.org', port: 9000, path: '/peer/'});

Apparently, I get an id, but after a while, this is the browser console result : enter image description here Thanks in advance :)

Shafayat Alam
  • 702
  • 1
  • 14
  • 32

1 Answers1

0

I noticed you're sending a wss request, this will need to go be proxy passed via ajax or nginx to get this to work properly as it's a secure protocol, are you doing this? Furthermore, how are you starting up the peer.js server? Is it hosted on the same box, are you manually starting it (ie: node server.js) or have you created some sort of service with init.d or upstart?

Furthermore, I beleive this: certificate: fs.readFileSync('./vchat247.hopto.org.crt') should be this cert: fs.readFileSync('./vchat247.hopto.org.crt') (although perhaps it accepts both)

Take a look at this references to help with setting up a proxy pass -

Community
  • 1
  • 1
jshbrmn
  • 1,737
  • 3
  • 22
  • 52