Я разрабатываю приложение для чата с openfire в качестве сервера xmpp и strophe.js в качестве клиентской библиотеки и использую ruby on rails на ubuntu.
Проблема в том, что strophe.js подключается к openfire, но дает статус AUTHFAIL и не создает пользователей. Он всегда возвращает статус 4 (AUTHFAIL).
openfire работает на >> localhost: 9090
приложение rails работает на >> localhost: 3000
служба 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') == "[email protected]/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>
Пожалуйста, помогите.