jrief / django-websocket-redis

Websockets for Django applications using Redis as message queue
http://django-websocket-redis.awesto.com/
MIT License
895 stars 221 forks source link

Websocket doesn't run after reloading whole site and starting uwsgi #275

Closed nrgx closed 5 years ago

nrgx commented 5 years ago

In my company chef made a file called reload. When things go wrong they use this file to reload whole all processes that are bind to our project (as I understood). But when everything is loaded and uwsgi up&running, the uwsgi that is responsible for websockets works improperly. I configure server 3rd time because of that file, and then eternal doom with uwsgi started. How should I configure my .ini file being ready for reloading?

This is my wsgi_websocket.ini file: [uwsgi] chdir = /home/user/project/ virtualenv = env http-socket = project/websocket.sock gevent = 1000 http-websockets = true workers = 20 master = true module = wsgi_websocket:application chmod-socket = 666 plugin = python processes = 10 touch-reload = project/(cursed)reload vacuum = true daemonize=/home/project/project.log

This is what Nginx gives (error.log): 2018/08/16 13:20:44 [error] 6628#6628: *1187 connect() to unix:/project/websocket.sock failed (111: Connection refused) while connecting to upstream, client: 37.151.221.217, server: budjet.kz, request: "GET /ws/test?subscribe-broadcast&publish-broadcast&echo HTTP/1.1", upstream: "http://unix:/home/project/websocket.sock:/ws/test?subscribe-broadcast&publish-broadcast&echo", host: "budjet.kz"

And uwsgi's response: you need to build uWSGI with SSL support to use the websocket handshake api function !!! Other Exception: unable to complete websocket handshake Traceback (most recent call last): File "/home/odmin/.local/share/virtualenvs/gos-EUVNjMGe/local/lib/python2.7/site-packages/ws4redis/wsgi_server.py", line 113, in __call__ websocket = self.upgrade_websocket(environ, start_response) File "/home/odmin/.local/share/virtualenvs/gos-EUVNjMGe/local/lib/python2.7/site-packages/ws4redis/uwsgi_runserver.py", line 52, in upgrade_websocket uwsgi.websocket_handshake(environ['HTTP_SEC_WEBSOCKET_KEY'], environ.get('HTTP_ORIGIN', '')) IOError: unable to complete websocket handshake Starting late response on websocket Finish non-websocket response with status code: 500 [pid: 6880|app: 0|req: 2/6] 0.0.0.0 () {44 vars in 891 bytes} [Thu Aug 16 13:22:31 2018] GET /ws/test?subscribe-broadcast&publish-broadcast&echo => generated 38 bytes in 2 msecs (HTTP/1.1 500) 1 headers in 78 bytes (3 switches on core 999)

Please, if you have any suggestion about reloading server, would you kindly share with me, because I'm fed up with eternal reconfiguring uwsgi and nginx.