Giter VIP home page Giter VIP logo

y-websockets-server's Introduction

(LEGACY) Websockets Connector for Yjs (Server)

Note: this is an outdated repository which is not compatible with y-websocket or Yjs>=v13

y-websockets-server is the connection point for y-websockets-client. It saves the shared data (using the memory or the leveldb database adapter), and distributes it efficiently to all connected clients.

Instructions for y-leveldb

The memory database adapter is installed by default. If you intend to use the y-leveldb database adapter, make sure to install it first.

npm install --save y-leveldb [-g]

Global installation (easy)

  • Install package npm install -g y-websockets-server
  • Execute binary y-websockets-server [--port port] [--db db] (defaults: port = 1234, db = memory (choose either leveldb or memory)).

Yjs uses debug for logging. In order to turn on logging set the environment variable DEBUG to y*,-y:connector-message: I.e

DEBUG=y*,-y:connector-message y-websockets-server --port 1234

This is how you redirect the output to a file:

DEBUG_COLORS=0 DEBUG=y*,-y:connector-message y-websockets-server --port 1234 > log.txt

Local installation (recommended if you intend to modify y-websockets-server)

  • Set up a new project

      mkdir my-y-websockets-server && cd $_ && git init && npm init && echo "node_modules" > .gitignore
    
  • Install npm i --save y-websockets-server

  • Copy executable cp node_modules/y-websockets-server/src/server.js .

  • Start server node server.js

Setup with Docker

  • Clone this repository and navigate to it.
  • Build the image: docker build -t y-websockets-server .
  • Run it: docker run -it --rm -p 1234:1234 --name y-websockets-server y-websockets-server
  • Feel free to modify the port argument, e.g. to -p 1773:1234 to run it at port 1773.

Setup with Heroku

Heroku is really easy to set up, and you get a free y-websockets-server with https! Preliminarily you have to set up heroku - see this great getting started guide

  • Perform the steps from the local installation

  • Create Procfile echo "web: DEBUG=y*,-y:connector-message server.js" > Procfile

  • Specify a node environment. Add this to your package.json:

      "engines": {
        "node": "6.9.1"
      }
    
  • Add heroku app heroku create my-websockets-server

  • Commit & Push to heroku git add -A && git commit -am 'init' && git push heroku master

  • Start app heroku ps:scale web=1

  • Get the url for your websockes-server instance heroku info (see Web Url).

y-websockets-server's People

Contributors

dmonad avatar istvank avatar joeao avatar

Stargazers

 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

y-websockets-server's Issues

Logging Improvements

Would be great to add as soon as possible a better logging mechamism for this.
Starting the websockets server Docker container, the only available console log output is of the form User X joins room: Y.
I would like to have also the timestamp included, or a better solution to log all messages. It is very important here that we have a location where the log file is stored and can be checked, regardless of the option taked for starting the Websocketsserver.

Critical dependency: the request of a dependency is an expression

Using y-websockets-server and y-websockets-client in a React app.

When running React app, it compiles with warnings:

Compiled with warnings.

./node_modules/yjs/src/y.js
74:10-29 Critical dependency: the request of a dependency is an expression

Line 74 of ./node_modules/yjs/src/y.js:

require(modulename)(Y)

npm install error

error: ‘class v8::Object’ has no member named ‘ForceSet’

it can't be installed for the package depends can't be installed in node version 10.x.x

Modifiable Socket Events

It would be useful to have access to the joinRoom, yjsEvent and disconnect events on both server and client.
By intercepting data being sent to the client and adding your own from the server, you'd be able to leave the following y-richtext issues up to QuillJS & websockets. #8, #85, #87, #88 and #99.
Should also help out with issue #95.

Docker image crashes

Following the instructions in the README file, the Docker image builds, but crashes on startup.

> [email protected] start /usr/src/app
> DEBUG=y*,-y:connector-message node ./src/server.js

module.js:341
    throw err;
    ^

Error: Cannot find module '../../yjs/y.node.js'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/src/app/src/server.js:5:11)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)

npm info lifecycle [email protected]~start: Failed to exec start script
npm ERR! Linux 4.9.87-linuxkit-aufs
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v5.12.0
npm ERR! npm  v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `DEBUG=y*,-y:connector-message node ./src/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'DEBUG=y*,-y:connector-message node ./src/server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the y-websockets-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     DEBUG=y*,-y:connector-message node ./src/server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs y-websockets-server
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls y-websockets-server
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/src/app/npm-debug.log

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.