Open ledzgio opened 3 years ago
If anyone is interested, I've managed to get it working on AWS.
Basically what I did is:
Edit the connection string in views.py as follows:
wss://domain.com/ws/session_id/username
Edit handlers.py, function main_handler to get username and session_id based on the new connection string defined above
Add this setting under nginx SSL server:
location /ws {
proxy_pass http://chatserver;
proxy_connect_timeout 7d;
proxy_read_timeout 7d;
proxy_send_timeout 7d;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
add the following outside the server directives:
upstream chatserver {
server 127.0.0.1:5002 max_fails=1 fail_timeout=20s;
}
and here are the settings.py:
CHAT_WS_SERVER_HOST = '127.0.0.1'
CHAT_WS_SERVER_PORT = 5002
CHAT_WS_SERVER_PROTOCOL = 'wss'
Now start the wesocket server as following:
python manage.py run_chat_server
Hope this help those that had issues like me. Cheers.
Description
I am having issues in production where I am running nginx on HTTPS and uwsgi deployed on an EC2 instance.
In the browser console I get this error: WebSocket connection to 'wss://ec2-***:5002/session_id/username' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR
What I Did
Here are my settings: CHAT_WS_SERVER_HOST = 'ec2-***' # here I am using EC2 Public IPv4 DNS CHAT_WS_SERVER_PORT = 5002 CHAT_WS_SERVER_PROTOCOL = 'wss'
I run the server as following: python manage.py run_chat_server
And in the server console I get:
Any idea? thanks