Code Monkey home page Code Monkey logo

rails-node-session's Introduction

Sharing session across different platforms

This experiment is intended to demonstrate the ease to share sessions between different technologies under the same umbrella (single login).

There are 2 different approaches: Using encripted cookies with the session information and using redis servers to store the sessions.

The load is balanced. The load banlancer decides if the request looks like a webpage and sends to a Ruby on Rails server or if the request looks like a WebSocket and sends it to a Node.js server.

TODO: Send the WebSocket request to the most available server instead of to the next in the round robin. Store the location of each connected user in a key/value storage to be able to push back to the particular server instead of broadcasting to all of them.

Setup

You can set up this environment using cookies or a session storage db (Redis).

You need node-rails-cookies package:

npm install node-rails-cookies

###Cookies###

railscookies/config/initializers/session_store.rb

Railscookies::Application.config.session_store :cookie_store, key: '_response_session'

websockets/index.js line 16

var session_store = 'cookies';

###Redis###

railscookies/config/initializers/session_store.rb

Railscookies::Application.config.session_store :redis_store_json,
   key: "_response_session",
   strategy: :json_session,
   domain: :all,
   servers: {
       host: :localhost,
       port: 6379
   }

websockets/index.js line 16

var session_store = 'redis';

Running

cd railscookies
rails server

cd websockets
node index.js

haproxy -f haproxy.conf

rails-node-session's People

Stargazers

Aaron McAdam avatar Philipp B. avatar tanakaworld avatar Chris Ostrowski avatar Kasparas Galdikas avatar Harrison Hogg avatar Julian Cohen avatar Steve Thomson avatar Alex Tan avatar Eric Young avatar

Watchers

Alfonso de la Osa avatar James Cloos avatar  avatar

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.