Running your own Peer Server

  1. Create a script in a new folder, perhaps called peer, and name the script something like "peerserver.js"
  2. Add this code to it:
    var fs = require('fs');
    var PeerServer = require('peer').PeerServer;
    var server = PeerServer({
      port: 9000,
      ssl: {
        key: fs.readFileSync('your.key'),
        cert: fs.readFileSync('your.crt')
  3. Put the key file and crt file I gave you into the same folder and point to them in the above code (replace your.key and your.crt with the right files).
  4. Upload the entire folder to your digital ocean server
  5. Using terminal, ssh to your digital ocean server, go into the folder you just uploaded and install the peer module
    npm install peer
  7. Then run the server    
    node peerserver.js
  8. In your web application you'll point to your server:
    var peer = new Peer('sergio1',{host: '', port: 9000, path: '/'});
  9. Make sure you have an on error so you can see any error messages
    peer.on('error', function(err) {
  10. If all works well, run it with forever.