Issue
Hello im trying to deploy my flask app on heroku. Im using flask_socketio module and socket.io in version 4.5(i didn't know how to initialize in 2.3.x version - io())
Here's my flask code:
from flask import Flask, render_template, url_for, redirect, session, request, jsonify
from flask_socketio import SocketIO
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
socketio = SocketIO(app)
#secret key etc...
...
@socketio.on('message')
def handle_msg(msg):
socketio.send('Syncing...')
if __name__ == '__main__':
socketio.run(app)
Here's my javascript:
...
export const socket = io();
socket.connect('https://proman-code-cool.herokuapp.com/');
function init() {
...
//live sync
socket.on('message', function(msg) {
console.log(msg);
boardsManager.reloadBoards(userId);
});
}
init();
And what i want is to make real-time sync to other users after adding something. And this is working locally but on heroku ive got all the time similar errors to:
When i've changed my Procfile to web: gunicorn -k eventlet main:app
and with installed eventlet 0.30.2 i've got errors like class uri 'eventlet' invalid or not found
. I can't find anywhere solution for that.
Solution
eventlet==0.30.2
in requirements.txt and python-3.8.13
in runtime.txt did the job!
Procfile: web: gunicorn --worker-class eventlet -w 1 main:app
Answered By - Deadjim
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.