Search code examples
node.jsserverwebrtchostingpeerjs

Hosting and deploy peerjs server


to help me with webRTC library 'peer.js'. To get it work i need a my-own server, so i try install peerjs on evennode.com. At hosting settings it's stated Startup command -> Detect automatically (recommended) (Your app is started with npm start in case package.json is available.).

So i did the next actions:

  1. created my new application-> http://mypeerjs.eu-4.evennode.com/
  2. unpacked and put in the hosting source my repository from https://github.com/peers/peerjs-server
  3. in that package .json there is: "scripts": { "test": "mocha test", "start": "peerjs --port 9000 --key peerjs" } also i tried to state (because i ran it from my local server)

    "start": "bin/peerjs --port ${PORT:=9000}"

The issue: The application doesnt start.The log writes next:

2018-01-27 18:41:41 102ea39d5429 ---> Starting app
2018-01-27 18:41:41 102ea39d5429 Detected package.json start script
2018-01-27 18:41:42 102ea39d5429 
2018-01-27 18:41:42 102ea39d5429 > [email protected] start /data/app
2018-01-27 18:41:42 102ea39d5429 > peerjs --port 9000 --key peerjs
2018-01-27 18:41:42 102ea39d5429 
2018-01-27 18:41:42 102ea39d5429 sh: 1: peerjs: not found
2018-01-27 18:41:42 102ea39d5429 npm ERR! [email protected] start: `peerjs --port 9000 --key peerjs`
2018-01-27 18:41:42 102ea39d5429 npm ERR! `sh "-c" "peerjs --port 9000 --key peerjs"` failed with 127
2018-01-27 18:41:42 102ea39d5429 npm ERR! 
2018-01-27 18:41:42 102ea39d5429 npm ERR! Failed at the [email protected] start script.
2018-01-27 18:41:42 102ea39d5429 npm ERR! This is most likely a problem with the peer package,
2018-01-27 18:41:42 102ea39d5429 npm ERR! not with npm itself.
2018-01-27 18:41:42 102ea39d5429 npm ERR! Tell the author that this fails on your system:
2018-01-27 18:41:42 102ea39d5429 npm ERR!     peerjs --port 9000 --key peerjs
2018-01-27 18:41:42 102ea39d5429 npm ERR! You can get their info via:
2018-01-27 18:41:42 102ea39d5429 npm ERR!     npm owner ls peer
2018-01-27 18:41:42 102ea39d5429 npm ERR! There is likely additional logging output above.
2018-01-27 18:41:42 102ea39d5429 
2018-01-27 18:41:42 102ea39d5429 npm ERR! System Linux 3.10.0-693.5.2.el7.x86_64
2018-01-27 18:41:42 102ea39d5429 npm ERR! command "/data/n/bin/node" "/data/n/bin/npm" "start"
2018-01-27 18:41:42 102ea39d5429 npm ERR! cwd /data/app
2018-01-27 18:41:42 102ea39d5429 npm ERR! node -v v0.9.1
2018-01-27 18:41:42 102ea39d5429 npm ERR! npm -v 1.1.59
2018-01-27 18:41:42 102ea39d5429 npm ERR! code ELIFECYCLE
2018-01-27 18:41:42 102ea39d5429 npm ERR! 
2018-01-27 18:41:42 102ea39d5429 npm ERR! Additional logging details can be found in:
2018-01-27 18:41:42 102ea39d5429 npm ERR!     /data/app/npm-debug.log
2018-01-27 18:41:42 102ea39d5429 npm ERR! not ok code 0

On my local server it's deployed successfully I unpacked the archive, moved to <path_to_peerjs-server>/bin and used a line to run it with node: node peerjs --port 9000 --key peerjs My server in my home net successfully run, browser peers connects to each other and everything works. HERE IS THE LOG FROM LOCAL SERVER But on the hosting it doesnt so i ask your help. In log, as i got,there is an error

18:41:42 102ea39d5429 npm ERR! peerjs --port 9000 --key peerjs

Thanks for advance!

EDIT i upploaded the application to my hosted server:

var http = require('http');
var server = http.createServer(function(req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello world!');
});
server.listen(process.env.PORT);

and it works,you may see it. I feel the problem is with listener port opening


Solution

  • let peer = new Peer({host:'peerjs-server.herokuapp.com', secure:true, port:443})
    

    rather than hosting your own peer server