Skip to content

Inconsistent socket emit while running multiple instances on docker #1497

Description

@codingram

We have a chatting application running on flask-socket-io. In this app, we have a end user, agent and manager.
Manager can see and reply all agents chats, agent can see and reply only the users connected to him/her. In the architecture, we are facing a issue where sometimes agent or manager does not receive any chats/messages emitted on room_id but when we refresh and rejoin manager/agent to same room_id, it works as expected. We checked the code and it looks fine. Most of the time, everything works as expected but we face this issue inconsistently. Is it the problem with architecture?

github backend issue

github issue frontend

import json
import os
import requests

# importing eventlet for monkey_patching
import eventlet
eventlet.monkey_patch()

from datetime import datetime
from flask import Flask, jsonify, request, send_file
from flask_cors import CORS
from flask_socketio import SocketIO, emit, join_room, send
from flask_celery import make_celery
from dateutil import parser
from celery.task.control import revoke
from celery.task.control import broadcast
from celery.result import AsyncResult

app = Flask(__name__)
app.config["SECRET_KEY"] = Config.SECRET_KEY
app.config['CELERY_BROKER_URL'] = os.environ.get('rabbit_path')
app.config['CELERY_BACKEND'] = os.environ.get('rabbit_path')

CORS(app)
celery = make_celery(app)

socketio = SocketIO(app, cors_allowed_origins="*", message_queue=os.environ.get('REDIS_URL'))


if __name__ == "__main__":
    socketio.run(app, debug=debug_flag, host="0.0.0.0", port=port)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions