Erlang 中的消息队列模型(Comet 聊天)?

发布于 2024-08-02 15:01:43 字数 271 浏览 3 评论 0原文

我正在用 Erlang 进行 Comet 聊天。我只使用一个连接(长轮询)进行消息传输。但是,如您所知,长轮询连接无法始终保持连接。每次有新消息到来或达到超时时,它都会中断,然后重新连接到服务器。如果在连接重新连接之前发送消息,那么保持聊天的完整性就会出现问题。

而且,如果用户使用 Comet-chat 打开多个窗口,则所有聊天消息都必须保持同步,这意味着用户可以拥有大量长轮询连接。因此,很难保证每条消息都按时送达。

我应该为每个连接建立一个消息队列吗?或者还有什么更好的方法来解决这个问题?

I am doing Comet chat with Erlang. I only use one connection (long-polling) for the message transportation. But, as you know, the long-polling connection can not be stay connected all the time. Every time a new message comes or reaches the timeout, it will break and then connect to the server again. If a message is sent before the connection re-connected, it is a problem to keep the integrity of chat.

And also, if a user opens more than one window with Comet-chat, all the chat messages have to keep sync, which means a user can have lots of long-polling connections. So it is hard to keep every message delivered on time.

Should I build a message queue for every connection? Or what else better way to solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何时共饮酒 2024-08-09 15:01:43

对我来说,让每个用户有一个进程/消息队列连接到聊天(甚至有多个聊天窗口)似乎是最简单的方法。跟踪聊天窗口应用程序中最后一条消息的时间戳,并在重新连接时询问此时间戳之后的消息。消息队列进程应该仅将消息保留合理的时间跨度。在这种情况下,重新连接完全取决于客户端。在另一种情况下,您可以从服务器发送某种心跳,但对我来说似乎不太可靠。它不能解决超时以外的其他原因断开连接的问题。服务器端队列有许多变体,每个客户端、每个用户、每个聊天室、每个......都有一个队列。

For me seems simplest way to have one process/message queue per user connected to chat (even have more than one chat window). Than keep track of timestamp of last message in chat window application and when reconnect ask for messages after this timestamp. Message queue process should keeps messages only for reasonable time span. In this scenario reconnecting is all up to client. In another scenario you can send some sort of hart beats from server but it seems less reliable for me. It is not solving issue with other reason of disconnection than timeout. There are many variant of server side queuing as one queue per client, per user, per chat room, per ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文