I have a flask server and an angularjs front end. I am trying to create a websocket that makes 3rd party API calls and spits out the results in an async fashion (using celery).
The current implementation works perfectly on my localhost dev environment. However, when I push it to my server, I get the following error:
WebSocket connection to 'wss://' failed: Error during WebSocket handshake: Unexpected response code: 200
I have given below the relevant codes for my front end, server and and nginx confguration files:
front end controller:
quotesocket = io.connect(myurl.url2,{'force new connection': true,'path':'/api/socket.io'});
quotesocket.on('connect', function(){
// console.log('socket');
});
...
and the rest of the code for event based emits go here
My nginx configuration:
sites-available (this is inside the 80 block. I redirect all traffic to https and I use a certbot SSL):
location /quote1{
proxy_pass http://127.0.0.1:5000/quote1;
proxy_http_version 1.1;
#proxy_redirect off;
proxy_buffering off;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
nginx.conf:
http {
##
# Basic Settings
##
##
# Timeout settings for proxy connections
##
proxy_connect_timeout 150s;
proxy_read_timeout 150s;
.....
}
My flask server:
@socketio.on('connect', namespace='/quote1')
def test_connect():
"""code for connecting"""
I have defined separate defs for events (connect, disconnect_request, disconnect, my_event, etc)
Can anyone here let me know where im going wrong?
Regards, Galeej