i am try to connect socket with angular app with flask_socket library but when i try to connect with live server which deploy on aws ec2 its give error code of 404 but its working if i run flask server localy
app = Flask(__name__)
socketio = SocketIO(app,cors_allowed_origins='*')
CORS(app, resources={r"/*": {"origins": "*"}})
@socketio.on('connect')
def handle_connect():
print('Client connected')
@socketio.on('message')
def handle_message(message):
print('Received message:', message)
emit('response', 'Server received: ' + message)
if __name__ == "__main__":
socketio.run(app,debug=True,host='0.0.0.0',port=8000)
also i configure nginx
location / {
proxy_pass http://localhost:8000;
location /socket.io {
include proxy_params;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://localhost:8000/socket.io;
} }
New contributor
JAY KANANI is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.