2

I am attempting to move my server off my local subnet and to a domain. The main webpages are working and I have them behind an SSL. Apache does a rewrite of the url from any HTTP connection to an HTTPS. However when I attempt to connect with javascript from in browser with:

new WebSocket("wss://" + window.location.host);

I receive the following error:

WebSocket connection to 'wss://{MY_WEBSITE}.com/message_route/' failed: Error during WebSocket handshake: Unexpected response code: 404

My config for the settings.py is as follows:

"default": {
    "BACKEND": "asgi_redis.RedisChannelLayer",
    "ROUTING": "my_app.routing.channel_routing",
    "Config": {
            "hosts": [os.environ.get('REDIS_URL', 'redis://127.0.0.0:6379')],
    }
},

EDIT (ADDED IN APACHE CONFIG DATA):

My Apache default.conf is the following (simple re-write to HTTPS):

<VirtualHost *:80>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
</VirtualHost>

Apache secure.conf:

<VirtualHost *:443>
    ServerName my_domain.com
    SSLEngine on
    SSLProxyEngine on
    SSLCertificateFile  /etc/ssl/my_domain/my_domain.crt
    SSLCertificateKeyFile /etc/ssl/my_domain/myserver.key
    SSLCACertificateFile /etc/ssl/my_domain/my_domain.ca-bundle

    Alias /static /home/user/my_app/myApp/static_files

    <Directory /home/user/my_app/myApp/static_files>
        Require all granted
    </Directory>

    <Directory /home/user/my_app/myApp/MyApp>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
    WSGIDaemonProcess MyApp python-path=/home/user/my_app/myApp/MyApp
    WSGIProcessGroup MyApp
    WSGIScriptAlias / /home/user/my_app/myApp/MyApp/MyApp/wsgi.py
</VirtualHost>

EDIT Found out apache is receiving request but not doing anything I tailed other_vhosts.access.log and found that when I created a new websocket in chromes console, apache logs that a GET request, but does not seem to forward it to my django app.

I also have a worker running, a redis server set up, and daphne running as well. Please let me know if you can think of any possible solutions to this problem

swrap
  • 314
  • 1
  • 3
  • 11
  • please include your apache conf file... – Raja Simon Sep 09 '16 at 06:35
  • Added the apache configs. Do you think that apache is not forwarding it on? Because when I attempt to connect with the wss django does not send me an error email. (Django sends error's to my email because it is in deployment, I added my email as part of the admins) – swrap Sep 09 '16 at 19:44
  • do you find the solution?. I have the same issue. – Darwin Jan 04 '18 at 21:34
  • 1
    @Darwin I have since moved onto this project. But if I can remember correctly what was missing was a websocket module that I needed for the apache server. I am sorry I could not be more help, but best of luck. – swrap Jan 08 '18 at 05:06

0 Answers0