【问题标题】:Not receiving the communication from Openfire Xmpp while connecting throw stropes.js连接 throw stropes.js 时未收到来自 Openfire Xmpp 的通信
【发布时间】:2014-07-03 07:08:37
【问题描述】:

我正在尝试创建客户聊天。我可以看到旁遮普服务器的日志为发送 - 接收。但从未显示为 Strophes Connected 做了以下设置

1)设置Xmpp服务器

wget -O openfire.deb http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire_3.9.3_all.deb 并按照中所述完成设置 https://www.digitalocean.com/community/tutorials/how-to-install-openfire-xmpp-server-on-a-debian-or-ubuntu-vps 现在可以在 *****xmppserver.com 访问 openfire

2)在同一台服务器上设置旁遮普波什服务器 从github下载

https://github.com/twonds/punjab/blob/master/INSTALL.txt

并通过 twistd -ny punjab.tac 开始运行

etc/hosts 中添加为

127.0.0.1 *****xmppserver.com

3) 终于下载了最新的strophes.js 并编辑了basic.js

var BOSH_SERVICE = 'http://*****xmppserver.com:5280/http-bind';

输出显示为正在连接,永远不会连接!

function onConnect(status) {
        console.log(status);
        if (status == Strophe.Status.CONNECTING) {
            log('Strophe is connecting.');
        } else if (status == Strophe.Status.CONNFAIL) {
            log('Strophe failed to connect.');
            $('#connect').get(0).value = 'connect';
        } else if (status == Strophe.Status.DISCONNECTING) {
            log('Strophe is disconnecting.');
        } else if (status == Strophe.Status.DISCONNECTED) {
            log('Strophe is disconnected.');
            $('#connect').get(0).value = 'connect';
        } else if (status == Strophe.Status.CONNECTED) {
            log('Strophe is connected.');
            log('Send a message to ' + connection.jid +
            ' to talk to me.');

            connection.addHandler(onMessage, null, 'message', null, null,  null);
            connection.send($pres().tree());
        }
    }

【问题讨论】:

  • 从未使用过旁遮普语,但 Openfire 有自己的内置 BOSH conn 管理器。您可以在 Openfire 的管理面板上启用它:服务器 > 服务器设置 > HTTP 绑定。在您的“http://*****xmppserver.com:7070/http-bind/”上尝试使用它。
  • 也尝试过,但出现以下错误 XMLHttpRequest cannot load http://******xmppserver:7070/http-bind。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此不允许访问 Origin 'localhost'。
  • 您在本地主机上运行哪个服务器?如果 Apache 则添加类似 ProxyPass /http-bind http://******xmppserver:7070/http-bindProxyPassReverse /http-bind http://******xmppserver:7070/http-bind 的代理。
  • 那么你的 bosh url 将是http://localhost/http-bind/,并注意 http-bind 末尾的额外“/”。这对 Strophe 至关重要。
  • 额外的“/”是问题所在。使用 7070 一切正常 :) 并且没有向 apache 服务器添加任何 ProxyPass,我的基本疑问是我们将 bosh punjab 放在两者之间

标签: openfire strophe punjab


【解决方案1】:

您可以尝试使用 Openfire 内置的 BOSH http 连接管理器。在 Openfire 的管理面板上启用它:
Server > Server Settings > HTTP Binding,那么 BOSH URL 应该是这样的

var BOSH_SERVICE = 'http://*****xmppserver.com:7070/http-bind/';

/http-bind 的末尾加上/ 对Strophe 至关重要。

【讨论】:

  • 你能不能把它改成 7070 而不是 5280 我试过用 5280 但没有得到。 7070 工作正常
猜你喜欢
  • 1970-01-01
  • 2013-10-07
  • 2021-11-03
  • 1970-01-01
  • 2021-01-17
  • 1970-01-01
  • 1970-01-01
  • 2018-08-31
  • 1970-01-01
相关资源
最近更新 更多