【问题标题】:Strophe.js giving AUTHFAIL status alwaysStrophe.js 总是给出 AUTHFAIL 状态
【发布时间】:2013-06-23 02:38:23
【问题描述】:

我正在开发一个聊天应用程序,其中 openfire 作为 xmpp 服务器,strophe.js 作为客户端库,并在 ubuntu 上使用 ruby​​ on rails。

问题是 strophe.js 连接到 openfire 但给出 AUTHFAIL 状态并且不创建任何用户。它总是返回状态 4 (AUTHFAIL)。

openfire 正在运行 >> localhost:9090
在 >> localhost:3000
上运行的 rails 应用程序 BOSH 服务运行在 >> localhost:7070/http-bind/

代码:-

    <script>
    var BOSH_SERVICE = 'http://localhost:7070/http-bind/';
    var connection = null;

    jQuery('#connect').click(function(){
        connection = new Strophe.Connection(BOSH_SERVICE);
        connection.connect($('#enter_id').get(0).value + "@localhost", null, onConnect);
    });

    function onConnect(status)
    {
        console.log("status is >> " + status);
        if(status == 5){
            console.log("inside if status is >> " + Strophe.Status.CONNECTED);
            console.log("onConnect >> " + status);
       connection.send($pres().tree());
         connection.addHandler(notifyUser, null, 'message', "chat");
      console.log("onConnect >> handler added");
        }

    }



    function notifyUser(msg) 
    {
            console.log("notifyUser >> " + msg);
    //  if (msg.getAttribute('from') == "testuser@127.0.0.1/pingstream") {
            var elems = msg.getElementsByTagName('body');
            var body = elems[0];
            jQuery('#chat_msg').append(Strophe.getText(body));
    //  }
        return true;
    }



    jQuery('#send_msg').click(function(){
        var msg_to_send = $msg({
            to: jQuery('#send_to').val() + "@localhost",
            from: connection.jid,
            type: "chat"
        }).c("body").t("hi!");

        connection.send(msg_to_send.tree());
    });

</script>

请帮忙。

【问题讨论】:

  • 请发布节正文,包括请求和响应。
  • 您是否测试过 Openfire 是否可以与一些现有的 XMPP 客户端(如 Spark)一起使用?

标签: xmpp openfire strophe


【解决方案1】:

@amirinder007 您在代码中提供了错误的服务器名称。我研究了您的代码,发现您提供 localhost127.0.0.1 而不是您编写了配置了 openfire 的服务器名称(Hostname)和您还可以在 openfire 管理控制台的主页上看到它的名称,如 Mycomputer-pc 作为个人计算机的名称。

【讨论】:

    【解决方案2】:

    我猜这里提供的服务器名称是错误的。尝试将其设置为使用 openfire 注册的 hostname 而不是 localhost

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-09
      • 1970-01-01
      • 2016-11-24
      • 2018-07-04
      • 1970-01-01
      • 1970-01-01
      • 2019-05-17
      • 1970-01-01
      相关资源
      最近更新 更多