Pollchat is an in-browser multi-user chat app built on Apache Kafka using Websockets and Node.js
It was written by David Basden [email protected] as a demonstration/exploration of what Kafka can be used for. It's best if you read the introductory blog post as well to get some context.
This is seriously some write-once, throwaway code. The code is quick-and-dirty, has config harcoded up the wazoo, and comes with no guarantees. But it should work.
-
Have a working ZooKeeper and Kafka cluster
-
Get yourself a server with Node.js installed, and a webserver like apache or nginx
-
You'll also need to install a couple of Node.js modules for kafka and websocket support
npm install kafka npm install websocket
We found that on a current build of Node.js, it would throw errors relating to the
pick
module. Commenting out the offending line innode_modules/kafka/node_modules/std/std.js
seems to fix that up. -
Edit server.js and fill in your
kafkahost
andkafkaport
. Adjust thelistenport
as well if you want -
Now fire up the server.js daemon, something like daemontools is recommended for serious usage
-
Edit index.html and fill in the Node.js websocket listener details. Place it in a directory being served by apache/nginx/other
-
Hit the page from your browser, you've just started a chat client!