您的位置:首页 > 运维架构

使用agsXMPP SDK向Openfire发送文件的注意事项

2015-07-28 11:27 519 查看
使用agsXMPP向Openfire发送文件,一直被service-unavailable错误困扰,详细错误如片段1-1所示。使用agsXMPP自带的Demo MiniClient项目,可以正常发送文件,但在自己的项目中却发送失败。

片段1-1

<iq xmlns="jabber:client" to="6@im.huiyaosoft.com/XmppDemo" id="agsXMPP_5" type="error">
<si xmlns="http://jabber.org/protocol/si" id="a3536b74-8a75-4ce2-9d84-59088b31bba3"
profile="http://jabber.org/protocol/si/profile/file-transfer">
<file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="data.xlsx" size="9688"><range /></file>
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="form">
<field var="stream-method" type="list-single">
<option><value>http://jabber.org/protocol/bytestreams</value></option>
</field>
</x>
</feature>
</si>
<error type="cancel" code="503">
<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
</error>
</iq>


具体步骤:

1、搭建Openfire服务器,确保5222、7777端口正常,在服务器设置中已启用“文件传送代理”。

2、Openfire配置如图1-1所示,设置正确的xmpp.domain,例如im.openfire.com,确保域名可ping通。



图1-1
3、修改文件frmFileTransfer.cs中的const string PROXY = "proxy.ag-software.de"为const string PROXY = "proxy.im.huiyaosoft.com",其中域名必须遵循proxy.样式。

4、发送文件时,必须指定jid.Resource,否则报503错误,如片段1-2所示。。

片段1-2

Jid jid = new Jid(username + xmppDomain);
jid.Resource = xmppCon.Resource;
frmFileTransfer ft = new frmFileTransfer(xmppCon, jid);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: