M
M
MichaelMih2021-09-13 20:00:02
Redis
MichaelMih, 2021-09-13 20:00:02

How to make emit through redis in flask?

Hello! emit not working

Code
emit("message", respones, namespace='/app/auction', room="1")

But it accepts events from JS.

Initialization:
spoiler
from flask import Flask
from flask_socketio import SocketIO
from .db import DataBase
import eventlet
eventlet.monkey_patch()

socketio = SocketIO(logger=True, engineio_logger=True, cors_allowed_origins="*", async_mode='eventlet')
database = DataBase("base.db")
UPLOAD_FOLDER = 'uploads'

def create_app(debug=False):
    """Create an application."""
    app = Flask(__name__, static_url_path="", static_folder='/')
    app.debug = debug
    app.config['SECRET_KEY'] = 'gjr39dkjn344_!67#'
    app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    socketio.init_app(app, message_queue='redis://')
    return app


According to the emit logs, there is an event, but the site does not receive an event. Everything works without radishes.

received event "new_message" from FT3WMkqGYeDhWi6ZAAAJ [/app/auction]
emitting event "message" to 1 [/app/auction]
Cannot publish to redis... retrying
Cannot publish to redis... giving up

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question