Skip to main content

python websockets server using ampq

Project description

ampq-websockets

Websocket server based on websockets using ampq protocol for messaging

Tested on python 3.9.9

Requirements:

  • redis >= 2.9.1
  • pika >= 1.2.0
  • websockets >= 10.1

Installation:

pip install py-ampq-websockets-server

Usage:

Subscribing to room

Browser -> (subcribing to room) -> py-sockjs -> (assign id and add) -> redis

Sending data to room

  1. Py Framework -> (get connect by room) -> redis

( Django, Flask and etc. )

  1. Py Framework -> (put data) -> rabbitmq -> (data) -> py-sockjs -> (send data) -> Browser

Run

python src/ampq_websockets/runserver.py

Optional

Django integration

  1. Make Command in the project: <any_app>/management/command/websocket_server.py
from django.conf import settings

import ampq_websockets

class Command(BaseCommand):
    def handle(self, *args, **options):
        logger = logging.getLogger(__name__)
        logger.info('start django-websocket-server')
        ampq_websockets.start(settings.DJANGO_WEBSOCKET_SERVER)
  1. Make DJANGO_WEBSOCKET_SERVER in settings.py. Example:
DJANGO_WEBSOCKET_SERVER = {
    'RABBIT_SERVER': {
        "USER": "guest",
        "PASSWORD": "guest",
        "SERVER": {
            "HOST": "localhost",
            "PORT": 5672,
            "VHOST": "/"
        },
        "EXCHANGE_NAME": "sockjs",
        "EXCHANGE_TYPE": "direct",
        "QUEUE_NAME": "ws01"
    },
    'REDIS_SERVER': {
        "HOST": "localhost",
        "PORT": 6379,
        "DB": 0,
        "PASSWORD": None,
        "PREFIX": "sockjs:"
    },
    'HOST': '0.0.0.0',
    'PORT': 8083,
    'LOCATION': '/ws',
    'SECRET_KEY': 'PLEASE_SET'
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-ampq-websocket-server-0.1.7.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_ampq_websocket_server-0.1.7-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file py-ampq-websocket-server-0.1.7.tar.gz.

File metadata

  • Download URL: py-ampq-websocket-server-0.1.7.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for py-ampq-websocket-server-0.1.7.tar.gz
Algorithm Hash digest
SHA256 6956e000778e9f8051ee8207fab77ff7503647ad6d1f01c315bc8581f4830193
MD5 32805860dd9565b60e19f24acd38ebc6
BLAKE2b-256 2fd1d7ce53678cc4a9c1aeb013f505baf1ea6f13e558cf8ef3d022837f9cc044

See more details on using hashes here.

File details

Details for the file py_ampq_websocket_server-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: py_ampq_websocket_server-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for py_ampq_websocket_server-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d4b6fa6b929f3a989dec4c370511a30c9ba8a65f10214eef54a4b6be9506808f
MD5 ce1f64ca307ea2771b585181348d75bd
BLAKE2b-256 38add32332fee2898030abf0e5da56d4e75458b980ff9727a5088a34749ae17b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page