Code Monkey home page Code Monkey logo

node-video-chat's Introduction

Node.js Video Chat

You can try out a live demo here!

A video chat written in JavaScript using React, Node.js, GraphQL, and Socket.io. This app is entirely in-browser.

Features include:

  • User authentication system with JWT
  • Users can upload profile pictures which are stored in S3
  • Real time updates with GraphQL subscriptions
  • Instant messaging using GraphQL subscriptions
  • Peer to peer video chat using WebRTC and Socket.io

The back end is comprised of 4 servers:

  • A PostgreSQL server as the primary database
  • A GraphQL API with Redis-backed subscriptions
  • A socket.io server for signaling calls
  • A Redis server backing the publisher/subscriber for GraphQL subscriptions and maintains concurrency between socket.io connections if you want to have multiple instances of the signaling server running

The front end (served from the GraphQL server for SSR) uses React and Apollo to interface with the GraphQL API. It also contains a Redux store containing the video chat state and thunk actions which interact with the Socket.io server for signaling.

The app uses Twilio for STUN/TURN servers but I may use available Node.js libraries to implement that myself in the future.

Environmental variables:

  • APP_NAME determines which server to start when running the app (graphqlServer or signalServer)
  • PORT determines which port the server is listening on
  • NODE_ENV determines environment (production or development)
  • SIGNAL_SERVER_URL URL of socket.io server
  • AWS_ACCESS_KEY for S3 where profile pictures are kept
  • AWS_SECRET_KEY for S3
  • AWS_BUCKET bucket where profile pictures are stored
  • COOKIE_KEY encryption key for setting cookies for session auth
  • COOKIE_SECRET secret for setting cookies for session auth
  • DATABASE_NAME of Postgres database
  • DATABASE_HOST for Postgres
  • DATABASE_USER Postgres role
  • DATABASE_PASSWORD for Postgres
  • GRAPHQL_URI URI of GraphQL server
  • GRAPHQL_WS_URI WebSocket URI for GraphQL subscriptions
  • JWT_SECRET JWT encryption secret
  • REDISCLOUD_URL URI of Redis database
  • TWILIO_AUTH_TOKEN token for Twilio account (for STUN/TURN)
  • TWILIO_SID Twilio account SID

node-video-chat's People

Contributors

dcthetall avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-video-chat's Issues

Unclear local development workflow

This is an incredible project. I have been rolling my own version of this from scratch the past couple days, and stumbled upon this. I am thinking about scrapping what I have so far, and building on top of your work. I started working through the code, and it is not clear what sort of workflow you used to develop this locally. In package.json yarn start makes the assumption that webpack has already run and built the project. Did you start webpack from the command line? Did you have any sort of watchers set up/automatic rebuilds? Did you deploy to test all changes?

Apologies if I am missing something obvious.

What should I put in a Sequelize config file?

When I first tried to deploy this app to Heroku, I got an error saying no Sequelize config file in the config folder. I then created a config folder and put a config.json file inside it. I am wondering what to put inside it for the web app to work. Leaving it blank just results in an error as well.
Heroku output when leaving it blank:

       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  8.9.0
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 8.9.0...
       Downloading and installing node 8.9.0...
       Using default npm version: 5.5.1
       
-----> Installing dependencies
       Installing node modules (package.json + package-lock)
       
       > [email protected] install /tmp/build_2706e93a_/node_modules/uws
       > node-gyp rebuild > build_log.txt 2>&1 || exit 0
       
       
       > [email protected] install /tmp/build_2706e93a_/node_modules/bcrypt
       > node-pre-gyp install --fallback-to-build
       
       [bcrypt] Success: "/tmp/build_2706e93a_/node_modules/bcrypt/lib/binding/bcrypt_lib.node" is installed via remote
       
       > [email protected] install /tmp/build_2706e93a_/node_modules/node-sass
       > node scripts/install.js
       
       Downloading binary from https://github.com/sass/node-sass/releases/download/v4.13.1/linux-x64-57_binding.node
       Download complete
       Binary saved to /tmp/build_2706e93a_/node_modules/node-sass/vendor/linux-x64-57/binding.node
       Caching binary to /tmp/npmcache.hpotu/node-sass/4.13.1/linux-x64-57_binding.node
       
       > [email protected] postinstall /tmp/build_2706e93a_/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
       > node lib/post_install.js
       
       
       > [email protected] postinstall /tmp/build_2706e93a_/node_modules/node-sass
       > node scripts/build.js
       
       Binary found at /tmp/build_2706e93a_/node_modules/node-sass/vendor/linux-x64-57/binding.node
       Testing binary
       Binary is fine
       added 1314 packages in 42.263s
       
-----> Build
       Running heroku-postbuild
       
       > [email protected] heroku-postbuild /tmp/build_2706e93a_
       > NODE_ENV=production webpack; sequelize db:migrate;
       
module.js:538
    throw err;
    ^
Error: Cannot find module './config/webpack/public-path'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/tmp/build_2706e93a_/webpack.config.server.js:3:20)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
       
       Sequelize CLI [Node: 8.9.0, CLI: 4.0.0, ORM: 5.15.1]
       
       
ERROR: Error reading "config/config.json". Error: SyntaxError: /tmp/build_2706e93a_/config/config.json: Unexpected end of JSON input
       
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] heroku-postbuild: `NODE_ENV=production webpack; sequelize db:migrate;`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.hpotu/_logs/2021-01-10T07_56_49_457Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       If you're stuck, please submit a ticket so we can help:
       https://help.heroku.com/
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

The demo isn't working

For some reason the demo isn't working, when you call another person and the message to accept appears it never connects. It says: it wasn't able to reach.

Question regarding GraphQL and WebRTC

GraphQL has support for subscriptions that uses WebSocket behind the scenes, why is it needed to use Socket.io and not use the GraphQL subscription for things such as signaling? Is there a reason or it was just preference?

The other question I have is regarding the usage of Redux, as you are using Apollo that handles the state for you, why Redux?

Thank you very much

Error

When I run graphql server and hit / request then i got bellow error. Can you please help me on it?

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: GraphQL error: WHERE parameter "id" has invalid "undefined" value

server side rendering does not allow socket.io-client

Please tell me about installing app.

I have installed app.
But when I was starting the app , there were some errors.

PS C:\Users\Developer\Documents\node-video-chat> nodemon start
[nodemon] 2.0.3
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node start build/start.js

server side rendering does not allow socket.io-client

Listening on port 4000
Executing (default): SELECT 1+1 AS result
Connected to PostgreSQL database

gyp ERR! stack Error: Command failed: /usr/local/bin/python3.7

gyp ERR! stack Error: Command failed: /usr/local/bin/python3.7 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax

Keep up the good work bro

Unknown configuration for GRAPHQL_WS_URI

Hello. I managed to run the application, both for the signalingServer and the graphqlServer apps, however, the application complains that it can't connect to the web socket server URL I provided. What URL should be? The signaling server? If so, I don't seem to find any websocket serving procedure inside the signaling server. What am I missing?

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.