Git Product home page Git Product logo

faye-redis-node's Introduction

faye-redis Build Status

This plugin provides a Redis-based backend for the Faye messaging server. It allows a single Faye service to be distributed across many front-end web servers by storing state and routing messages through a Redis database server.

Usage

Pass in the engine and any settings you need when setting up your Faye server.

var faye  = require('faye'),
    redis = require('faye-redis'),
    http  = require('http');

var server = http.createServer();

var bayeux = new faye.NodeAdapter({
  mount:    '/',
  timeout:  25,
  engine: {
    type:   redis,
    host:   'redis.example.com',
    // more options
  }
});

bayeux.attach(server);
server.listen(8000);

The full list of settings is as follows.

  • host - hostname of your Redis instance
  • port - port number, default is 6379
  • password - password, if requirepass is set
  • database - number of database to use, default is 0
  • namespace - prefix applied to all keys, default is ''
  • socket - path to Unix socket if unixsocket is set

License

(The MIT License)

Copyright (c) 2011-2013 James Coglan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

faye-redis-node's People

Contributors

andrewarrow avatar jcoglan avatar peterdavehello 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

faye-redis-node's Issues

Zombie users left on channels

During destroyClient users get removed from /clients then channels. As a result if the server crashes at this point zombie users are left on channels.

Its a bit of an edge case but we have experienced on our setup. Currently we mitigate it using a cleanup script but it would be great if it wasn't need.

Improve how messages are published to avoid potential scalability issues

Hi,

It seems that the way the Redis backend is currently implemented, some scalability issues are bound to happen pretty quickly as soon as the message payload is not so small and there is a decent number of clients.

Looking on google, I saw a comment on hacker news on the same subject:

"I tried using faye and it died very quickly under load with the redis backend. For every message that you send it queues it up into a redis list for each faye server in the cluster to read which doesn't scale very well in their very chatty redis queue system."

The issue is the redis backend currenly maintains a queue of messages for each client. So the message and its payload is duplicated N times (N = number of clients) which is very not efficient.

Ideally, each message should be stored a single time in redis.

disable redis offline mode for v2.+ driver

{ enable_offline_queue: false } - pass this option.

Without it, new driver will collect requests on connection loss, instead of returning errors, to run after redis become alive. If you have intensive messaging, that can cause out of memory.

TypeError

any idea why I suddenly be getting these faye-redis errors:

TypeError: Object 01wp6m1vg1bky18m6n4n08h7hdc0rw7ewx0 has no method 'forEach'
at /node_modules/faye-redis/faye-redis.js:77:16

TypeError: Cannot call method 'map' of undefined
at Array.4 /node_modules/faye-redis/faye-redis.js:158:35)

I seem them on our production system all the time now but can't reproduce in development. This is our faye.NodeAdapter with a redis engine. Could it be something goes wrong with redis itself? Thanks, any pointers in some direction most appreciated.

Recent update to redis (2.6.1) causes messages not to be broadcast

I'm not exactly sure how to describe this except that publishing messages no longer works. I see subscriptions showing up in Redis. But no messages seem to be make it out. publish succeeds and there are no apparent errors.

From npm list --long --parseable | sort

NOT WORKING:

/app/node_modules/faye-redis/node_modules/redis:[email protected]:undefined
/app/node_modules/faye-redis:[email protected]:undefined
/app/node_modules/redis-parser:[email protected]:undefined

WORKING:

/app/node_modules/faye-redis/node_modules/redis:[email protected]:undefined
/app/node_modules/faye-redis:[email protected]:undefined
/app/node_modules/redis-parser:[email protected]:undefined

Push to NPM Please?

It's great that you removed hredis as some hosts have some trouble with the C extension. 8c69408#package.json

Would you please bump the version and push this to NPM?

Thanks!

Consistent Hashing?

Recently, I have had some serious problems, my redis server crashed after reaching its memory limit. I wonder if faye-redis will add support for consistent hashing to support multiple redis servers in the future?

Errors from the redis library are ignored

Hi!

We are currently using the library and we experience critical issues with it. Sometimes , due to network errors, our redis server becomes unreachable for a small amount of time, creating errors such as:

17 Dec 15:44:57 - Error: Redis connection to redisx.mdx2mz.0001.use1.cache.amazonaws.com:6379 failed - connect ETIMEDOUT
    at RedisClient.on_error (/var/www/app/node_modules/redis/index.js:189:24)
    at Socket.<anonymous> (/var/www/app/node_modules/redis/index.js:95:14)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:441:14

After some investigation we realised that most errors from the redis library are ignored and that there's no handler for the default error event of both this._redis and this._subscriber.

Also, in most callbacks, the error event is ignored, being an open door to unhandled exceptions.

i.e. In the following, when error is defined, clients isn't:

var notify = function(error, clients) {
  clients.forEach(function(clientId) {
    var queue = self._ns + '/clients/' + clientId + '/messages';

    self._server.debug('Queueing for client ?: ?', clientId, message);
    self._redis.rpush(queue, jsonMessage);
    self._redis.publish(self._messageChannel, clientId);

    self.clientExists(clientId, function(exists) {
      if (!exists) self._redis.del(queue);
    });
  });
};

Throwing TypeError: Cannot call method 'forEach' of undefined.

Hope we can help to get this fixed. Thanks!

Feature: Configurable key separators

I think it would be a good idea to be able to configure your own convention for key separators. As of now they are hardcoded with /. It would be nice if you could decide the separator and use things like :

Example:

var server = new faye.NodeAdapter({
  mount:    '/',
  engine: {
    type:   redis,
    namespace: "myapp:faye"
    separator: ":"
  }
});

would yield keys in redis like this

myapp:faye:clients
myapp:faye:clients:3es90n06y8ogw1ujirun18wgg4l1vsuuk40:channels

Thoughts?

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.