与RabbitMQ一起使用时,烧瓶射击不会从前端收集消息



我正在尝试设置"烧瓶"应用程序以使用兔子队作为消息队列。如果我从服务器发出消息,它可以正常工作,但是如果我尝试发出消息,什么也不会发生。似乎前端插座没有与队列通信。

我的插座代码如下:

from flask_socketio import emit, SocketIO
socketio_mp = SocketIO(message_queue='amqp://guest:guest@localhost:5672//')
@socketio_mp.on('connected', namespace='/test')
def joined():
    """Sent by clients when they enter a room.
    A status message is broadcast to all people in the room."""
    print('connected')

插座的初始初始化,如烧瓶存放文档所示。即使从前端排放出来,connected事件也永远不会触发。

var namespace = "/test";
socket = io.connect(location.protocol + "//" + document.domain + ":" + location.port + namespace);
socket.on("connect", function() {
    console.log("connected");
    socket.emit("connected", {msg: "next"});
});

我在控制台上也没有错误。

创建SocketIO实例时,必须将烧瓶应用程序作为第一个参数传递:

socketio_mp = SocketIO(app, message_queue='amqp://guest:guest@localhost:5672//')

作为旁注,我不确定以这种方式添加消息队列时,您期望有什么不同。客户从不与消息队列交谈。当您具有多个烧瓶插座服务器或仅发射的过程时,将使用队列使用。客户无法直接访问队列。

最新更新