简体   繁体   中英

deploying meteor app on a EC2 AWS server

i'm currently working on a school project :

I have to use PeerJS, Meteor and WebRTC to make a video chat app.

Mine is based on this tutorial , only with added CSS.

I successfully managed to create one that works locally (everything works fine on localhost:3000 once the

meteor

command is run in the project folder.

I'm working on windows 10, and I used mupx to deploy the app on my EC2 server.

i followed this tutorial and everything worked fine, i can access my app, login and see my webcam feed. but once i try to call another user, the link isn't made. i think it's because the mongoDB or meteor service lacks something but i can't figure out what.

My mup.json looks like this :

{
  "servers": [
    {
      "host": "IP.OF.METEOR.APP.EC2",
      "username": "ubuntu",
      "pem": "C:/Path/to/file.pem"
    }
  ],
  "setupMongo": true,
  "enableUploadProgressBar": true,
  "appName": "PeerChat",


  "app": "C:/pth/to/PeerChat",
    "buildOptions": {
     "debug": true,
     "executable": "meteor"
  },
  "env": {
      "PORT" : 80,
      "ROOT_URL" : "http://ec2-ip-to-meteor-app.us-west-2.compute.amazonaws.com",
      "MONGO_URL" : "http://IP.TO.MONGO.EC2:27017"
  },
  "deployCheckWaitTime": 300
}

Could someone give me advice on how to successfully deploy my app ? I've been trying lots and lots of things but none worked so far.

Thanks for your help !

Recently browsers changed to prevent webrtc over http. If you try to run it you'll get some kind of access denied error in your console log.

It means that everything needs to be run using https. In your case this means Meteor and the peerjs-server.

Looking at the mupx documentation, I'm going to assume that's working ok for you, it uses nginx itself, so it should be ok. Doing it yourself is quite possible, but some sysadmin capability is required. That is also true (to a lesser extent with peerjs-server)

Peerjs server

The peerjs-server is available at https://github.com/peers/peerjs-server As it stands it can be run from the command line, but the problem is that tools like nginx/Passenger don't do command line options, so I made a fork that accepts environment variables. My fork is at https://github.com/mikkelking/peerjs-server

This is the startup file for peerjs-server which uses a thing called forever. https://github.com/foreverjs/forever

A simple CLI tool for ensuring that a given script runs continuously (ie forever).

Pre-requisites:

  • Nodejs
  • A User called peerjs
  • My port of peerjs-server unpacked to /var/www/peerjs
  • An understanding of how to install and run forever

Script to run peerjs-server:

#!/bin/bash
export PEERJS_PORT=9000;
export PEERJS_KEY=some-unique-string;
export PEERJS_SSLKEY=/etc/nginx/ssl/myserver.key;
export PEERJS_SSLCERT=/etc/nginx/ssl/myserver.pem;
export PEERJS_DEBUG=1;
cd /var/www/peerjs

forever start -l forever.log --append -o out.log -e err.log ./bin/peerjs --debug 2&>1 >./peerjs.log

This script will ensure that peerjs will run even after crashing, and will survive a reboot of the server.

You might also need this file:

~peerjs/.forever/config.json

{
  "root": "/home/peerjs/.forever",
  "pidPath": "/home/peerjs/.forever/pids",
  "sockPath": "/home/peerjs/.forever/sock",
  "loglength": 100,
  "logstream": false,
  "columns": [
    "uid",
    "command",
    "script",
    "forever",
    "pid",
    "id",
    "logfile",
    "uptime"
  ]
}

I hope this helps.

If this is just a demo, you don't need to go and set up a whole web site. You can do it with a port forward to allow a second machine to participate.

Let's say you are running meteor on port 3000 on your local machine. Work out what your local network ip address is, something like 192.168.1.101

On the second machine do a port forward with a command like this:

ssh -L 3000:192.168.1.101:3000 localhost

It will ask you to provide the password of the local user.

Now that user can go to localhost:3000 and access your meteor app. Video calling will be allowed, because the browser thinks you are on the local machine

The other option is to use an anonymous window on the same machine and log in as a different user. Not as good as doing it on 2 computers though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM