Skip to content

gleicon/pubsub_comet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simplified PUB/SUB with node.js:

- Binds into a redis channel called PUBSUB:COMET
- send everything received by this channel straight to connected users
- used COMET as transport

test with curl or any browser (some browsers as safari and chrome has a minimum buffer to fill before showing comet data)

start redis and run pubsub_comet:
$ node pubsub_comet.js

in another term
$ curl http://localhost:8080/subscribe

now publish messages to redis:

$ redis-cli
> PUBLISH PUBSUB:COMET hello

check curl's output and note that the connection still there.

also, use publisher.js to test a stream of search results from twitter to your users.

$ node publisher.js

--------
Exploratory testbed using comet_test.js

comet_test.js has the same URL scheme, but exposes a /publish url so you can use curl as:

$ node comet_test.js

in other terminal
$ curl -X POST -d 'body=test' http://localhost:8080/publish to send data instead of redis.


---------
if you keep getting too many open files error, try: 
$ launchctl limit maxfiles 1000000 1000000

In Linux, try:
$ sudo bash
# ulimit -n 999999

you can check with both strace (linux) and dtruss (mac os X) if your node.js binary is using epoll and kevent (kqueue) respectively. Select will balk on 1024 clients on mac.


The tests/ folder carries assorted testes made in different languages. Try comet_cont.py opening 5k clients each time (simulating a ramp up).
chatter.js is intended to be a real chat simulation.

gleicon - 2010 - http://zenmachine.wordpress.com | http://github.com/gleicon

About

Pub/Sub using Redis, Node.js and COMET as transport - work in progress

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages