Skip to content

About

websockets for tippr

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

tippr-service-websockets

Websockets for tippr: live comments, vote counts and other updates pushed to open pages.

This is tippr's maintained fork of reddit's reddit-service-websockets, ported to Python 3 and tippr's baseplate fork, with AMQP through py-amqp instead of haigha. The Python package keeps its original name (reddit_service_websockets) so existing configs keep working. tippr's installer clones and installs this repository (TIPPR_WEBSOCKETS_REPO) and runs it as tippr-websockets.service.

This service is primarily aimed at broadcasting messages to clients. It can also optionally report to the backend when clients connect or disconnect. All communication with other backend services is mediated by an AMQP broker (RabbitMQ).

Usage

Applications using this service are in charge of managing authorization. The service validates that incoming requests were authorized by the main application using a message authentication code. The path portion of a websocket request indicates which message "namespace" the socket will receive.

Messages are sent to the service via an AMQP fan out exchange. Each worker process binds to the exchange and will receive all messages sent to it. Messages are dispatched to appropriate websocket clients by mapping the message's routing key to the socket namespace specified in the websocket request.

If configured to do so, the service will also insert connect/disconnect messages onto a topic exchange in AMQP.

Testing and Development

There are two Docker images provided for development and testing.

  • Dockerfile: A Docker image definition for running a local version of the service.
  • Dockerfile.test: A Docker image definition for running tests.
# Exposes websocket service at 127.0.0.1:9090
docker build . -t ws-server -f Dockerfile  && docker run --rm -p 9090:9090 ws-server

# Run code tests
docker build . -t ws-tests -f Dockerfile.test  && docker run ws-tests

Further reading

The client and server code that talks to this service is in tippr:

License and credit

BSD 3-clause (LICENSE). Original code © reddit Inc.; changes since the fork by TechIdiots LLC.

About

websockets for tippr

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages