I tried to build a Flask application including socket io server. It works well on local side. But when I deployed on aws ec2 instance(ubuntu system), I got following error.
websocket connection issue
Here is my nginx configuration.
nginx configuration
Client side code snippet is as follows.
var socket = io.connect('/', {
transports: ["websocket"],
cors: {
origin: "*",
},
});
Server side code snippet is as follows.
from flask_socketio import SocketIO
from flask_cors import CORS
app = Flask(__name__)
CORS(app,resources={r"/*":{"origins":"*"}})
socketio = SocketIO(app,cors_allowed_origins="*")
I am not sure how to fix
I tried to figure it out by adding nginx configuration, but it didn’t work.