RocketWS is open-sourced WebSockets push server based on gevent-websocket library

Several main types of server interactions are supported:
All requests must be correspond to JSON-RPC 2.0 Specification
WebSockets
Subscribe to channel chat:
{"id": 0, "jsonrpc": "2.0", "method": "subscribe", "params": {"channel": "chat"}}
Unsubscribe from channel chat:
{"id": 0, "jsonrpc": "2.0", "method": "unsubscribe", "params": {"channel": "chat"}}
Send data to channel chat:
{"id": 0, "jsonrpc": "2.0", "method": "send_data", "params": {"channel": "chat", "data": {"message": "hola!"}}}
MessagesSources
chat: {"id": 0, "jsonrpc": "2.0", "method": "emit", "params": {"channel": "chat", "data": {"message": "hola!"}}}{"id": 0, "jsonrpc": "2.0", "method": "notify_all", "params": {"data": {"message": "Broadcase system message"}}}Command line interface is console for WebSockets clients interaction, this feature emulate MessagesSource connector with console.
make shellhelp for more informationNOTE: For remote shell you need to ensure that port for MESSAGES_SOURCE is available on a server.
Run remote shell: python manage.py shell --ms-conn http://rocketws.domain.com:80/shell
Main settings files are stored as rocketws/settings/{environment}.py
Common and recommended settings are already predefined.
Otherwise you can configure it with manage.py command. See more information in Management section.
There are several parameters:
MESSAGES_SOURCE -- control MessagesSource parameters for backend interaction. Default port: 59999
WEBSOCKETS -- control WebSockets server parameters for clients interaction. Default port: 58000
LOGGING -- logging configuration
Main application management available with manage.py script.
Commands:
runserver - Start RocketWStests - Run testsshell - Run command-line interfaceOptions:
--settings - Application settings. Format: --settings=rocketws.settings.{environment} Predefined environments: production, default, test. Default: --settings=rocketws.settings.default--ws-conn - WebSockets server connection options. Example: --ws-conn 0.0.0.0:58000 or --ws-conn :58000. Options for runserver command.--ms-conn - MessagesSource connection options. Format is the same as --ws-conn. Options for runserver and shell command.Make sure that you have libevent-2.0-5 or libev4 in your system.
git clone https://github.com/prawn-cake/RocketWS.git {dir}cd {dir} && make env{dir}/rocketws/settings/default.pymake run OR {dir}/manage.py runserverNOTE: By default --settings=rocketws.settings.default will be passed to manage.py, you can change it with
make run SETTINGS=rocketws.settings.production OR {dir}/manage.py runserver --settings=rocketws.settings.production
sudo aptitude install supervisor # Debian-waysudo vim /etc/supervisor/conf.d/rocketws.confNOTE: For production using need to create log directory /var/log/rocketws
[program:rocketws]
# For development
command={dir}/.env/bin/python {dir}/manage.py runserver
# For production recommended
# command={dir}/.env/bin/python {dir}/manage.py runserver --settings=rocketws.settings.production
autostart=false
autorestart=true
user={str:user}
# stdout_logfile=/tmp/rocketws.log
sudo supervisorctl reread && sudo supervisorctl updatesudo supervisorctl start rocketwsNOTE: Docker works fine (without any workarounds) only under x86_64 arch (based on my tests)
DOCKER_OPTS="--ip 127.0.0.1" to /etc/default/docker (or /etc/sysconfig/docker for RHEL) and restart the docker serviceNOTE: use sudo with the following commands or add your user to a docker group
docker pull prawncake/rocketwsdocker run --name rocketws -it -p 58000:58000 -p 59999:59999 prawncake/rocketws /bin/bashmake run_bg SETTINGS=rocketws.settings.productionCtrl+p Ctrl+qNOTE: For some reasons docket can't run nohup, disown, & shell instructions from command line or within Makefile commands
Container will be started and then you can connect to tcp:58000 for WebSockets and to tcp:59999 for MessagesSource
rocketws container: docker attach rocketwsCtrl+p Ctrl+qdocker ps -adocker {start|stop|rm} rocketwsNOTE: We use exact name because we set it up in run command as a --name option otherwise we must use container ID
Useful for production
Add custom proxy_read_timeout, because it equals 60s by default, proxy_read_timeout 604800; # one-week timeout; for example
Content type
Image
Digest
sha256:49cd1b826…
Size
186.5 MB
Last updated
almost 11 years ago
docker pull prawncake/rocketws