python - Websocket connection by Apache2 + mod_wsgi + Django -


i deploying django project on apache2 using mod_wsgi. can confirm see django's page apache2 server websocket cannot connect, think django-channels doesn't start apache2.

so solve problem install 'asgi_redis' start django-channels.

'pip3 instal asgi_redis' 

i changed channel layer.

channel_layers = {     "default": {         "backend": "asgi_redis.redischannellayer",             "config": {             "hosts": [("localhost", 6379)],              },             "routing": "mysite.routing.channel_routing",     }, } 

and tried follow command.

'python3 manage.py runworker' 

but following error occured.

2017-07-27 08:07:59,660 - info - runworker - using single-threaded worker. 2017-07-27 08:07:59,661 - info - runworker - running worker against channel  layer default (asgi_redis.core.redischannellayer) 2017-07-27 08:07:59,663 - info - worker - listening on channels  http.request, websocket.connect, websocket.disconnect, websocket.receive traceback (most recent call last):   file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 439, in connect     sock = self._connect()  file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 494, in _connect raise err file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 482, in _connect sock.connect(socket_address) connectionrefusederror: [errno 111] connection refused  during handling of above exception, exception occurred:  traceback (most recent call last): file "/usr/local/lib/python3.5/dist-packages/redis/client.py", line 572, in execute_command connection.send_command(*args) file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 563, in send_command self.send_packed_command(self.pack_command(*args)) file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 538, in send_packed_command self.connect() file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 442, in connect raise connectionerror(self._error_message(e)) redis.exceptions.connectionerror: error 111 connecting localhost:6379.  connection refused.  during handling of above exception, exception occurred:  traceback (most recent call last): file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 439, in connect sock = self._connect() file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 494,in _connect raise err file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 482,  in _connect sock.connect(socket_address) connectionrefusederror: [errno 111] connection refused  during handling of above exception, exception occurred:  traceback (most recent call last): file "manage.py", line 24, in <module> execute_from_command_line(sys.argv) file "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() file "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 355, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) file "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) file "/usr/local/lib/python3.5/dist-packages/channels/management/commands/runworker.py", line 83, in handle worker.run() file "/usr/local/lib/python3.5/dist-packages/channels/worker.py", line 87, in run channel, content = self.channel_layer.receive_many(channels, block=true) file "/usr/local/lib/python3.5/dist-packages/asgiref/base_layer.py", line 43, in receive_many return self.receive(channels, block) file "/usr/local/lib/python3.5/dist-packages/asgi_redis/core.py", line 215, in receive result = connection.blpop(list_names, timeout=self.blpop_timeout) file "/usr/local/lib/python3.5/dist-packages/redis/client.py", line 1163, in blpop return self.execute_command('blpop', *keys) file "/usr/local/lib/python3.5/dist-packages/redis/client.py", line 578, in execute_command connection.send_command(*args) file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 563,  in send_command self.send_packed_command(self.pack_command(*args)) file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 538,  in send_packed_command self.connect() file "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 442,  in connect raise connectionerror(self._error_message(e)) redis.exceptions.connectionerror: error 111 connecting localhost:6379. connection refused. 

need in resolving error.

raspberry pi 3 ubuntu 16.04.2 django 1.11.1 apache2 2.4.18


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -