Skip to content

Latest commit

 

History

History
21 lines (12 loc) · 1.59 KB

README.md

File metadata and controls

21 lines (12 loc) · 1.59 KB

Websockets, Ratchet, Redis pubsub test

This is a proof of concept HTML5 websocket app showing how ratchet and websockets can be used along with Redis' pubsub publish and subscribe.

You can use the form below to subscribe/unsubscribe to a channel. When you subscribe you also subscribe to the corresponding Redis channel. So if using the cli you connect to Redis and do a PUBLISH channel:jmoz foo, the message will be published from Redis to the websocket server then to the browser.

You can publish via websockets to the WS server which will then broadcast to connected clients. This does not touch Redis.

You can make an AJAX request to this app which will then use Redis and PUBLISH which will be picked up by the WS server and broadcast to clients. This is a way to demo the raw Redis pubsub without using the cli.

The following tech is used:

  • Ratchet - the core WAMP app that uses an event loop, handles websockets and subscribes to Redis.
  • Predis-async - the client library for Redis that implements the react event loop.
  • Silex - used as the framework and provides the AJAX endpoint to publish via Redis.
  • AutobahnJS - the JS library to implement websockets.

Source code is on github jmoz/silex-test. App is running at silex-test.jmoz.co.uk/pubsub.

Developed by James Morris. Blog. @jwmoz.