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
- Py Framework -> (get connect by room) -> redis
( Django, Flask and etc. )
- Py Framework -> (put data) -> rabbitmq -> (data) -> py-sockjs -> (send data) -> Browser
Run
python src/ampq_websockets/runserver.py
Optional
Django integration
- 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)
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6956e000778e9f8051ee8207fab77ff7503647ad6d1f01c315bc8581f4830193 |
|
MD5 | 32805860dd9565b60e19f24acd38ebc6 |
|
BLAKE2b-256 | 2fd1d7ce53678cc4a9c1aeb013f505baf1ea6f13e558cf8ef3d022837f9cc044 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4b6fa6b929f3a989dec4c370511a30c9ba8a65f10214eef54a4b6be9506808f |
|
MD5 | ce1f64ca307ea2771b585181348d75bd |
|
BLAKE2b-256 | 38add32332fee2898030abf0e5da56d4e75458b980ff9727a5088a34749ae17b |