【发布时间】:2014-08-15 04:08:05
【问题描述】:
我已使用跨域的示例连接到我的本地 openfire xmpp 服务。 只需更改 BOSH url 以适应我的本地 openfire 服务。
我测试了什么,所以我知道 openfire 本身可以工作。我可以成功连接 Pidgin。
(网站在码头内运行)
(实际的)openfire 安装在 localhost 上运行
提交表单后执行 strophe javascript 表单域:#jid = 'admin@localhost' 表单域:#pass = 'mypassword'
rawInput 和 rawOutput 函数被省略,它们只是记录传输的内容。
var BOSH_SERVICE=http://localhost:8080/xmpp-bosh
function onConnect(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.');
connection.disconnect();
}
}
$(document).ready(function () {
connection = new Strophe.Connection(BOSH_SERVICE);
connection.rawInput = rawInput;
connection.rawOutput = rawOutput;
$('#connect').bind('click', function () {
var button = $('#connect').get(0);
if (button.value == 'connect') {
button.value = 'disconnect';
connection.connect($('#jid').get(0).value,
$('#pass').get(0).value,
onConnect);
} else {
button.value = 'connect';
connection.disconnect();
}
});
});
连接示例时出现错误给我以下日志输出:
Strophe is connecting.
SENT: <body rid='4005617322' xmlns='http://jabber.org/protocol/httpbind' to='localhost' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>
RECV: <body xmlns='http://jabber.org/protocol/httpbind' authid='' condition='remote-stream-error' inactivity='600' polling='10' requests='2' secure='false' sid='orw55e6kuyZ0F-CFgnxXWMzG' type='terminate' wait='60'><starttls xmlns=''/><mechanisms xmlns=''><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><compression xmlns=''><method>zlib</method></compression><auth xmlns=''/><register xmlns=''/></body>
Strophe failed to connect.
Strophe is disconnected.
任何想法如何克服这个问题? (已经用 pidgin IM 测试过并且可以工作)
【问题讨论】: