ejabberd xmpp 连接未维护
我使用 jQuery 和 Ejabberd 创建了一个网络聊天应用程序(来自 Professional XMPP Book 的示例)。对于此应用程序,我实现了匿名身份验证(这是一个要求)。 当用户访问该网站时,根据他的用户名,我进行身份验证并授予对 XMPP 聊天的访问权限。使用共享名册,他可以看到所有其他用户并与他们聊天。 但是,当刷新页面或移动到另一个页面时,我需要再次创建一个新连接,并且它挂在“正在连接”状态。 我该如何解决这个问题? 提前致谢。
I've created a web-chat application using jQuery and Ejabberd (example from Professional XMPP Book). For this application, I've implemented anonymous authentication (was a requirement).
When user visits the site, according to his username, I authenticate and give access to XMPP Chat. Using shared roster, he can see all other users and chat with them.
However, when page is refreshed or moved to another page, I need to create a new connection again and it hangs on 'Connecting' state.
How can I solve this issue?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该调查您的客户端代码,因为它不应该发生。我亲自这样做过很多次并取得了成功。
然而,在编写 HTTP 客户端时,在每个页面上关闭并重新连接并不是一个好的做法,并且您将在扩展应用程序时遇到问题。
您应该研究重新连接到现有连接的方法。
You should investigate your client code, because it should not happen. I did this many times personally with success.
However, closing and reconnecting on each page is not a good practice when writing an HTTP client and you will have trouble scaling your application.
You should investigate way to reattach to existing connection.