在XMPP中使用iOS进行文件传输时出现服务不可用503错误 [英] service-unavailable 503 error for file transfer in XMPP with iOS

查看:195
本文介绍了在XMPP中使用iOS进行文件传输时出现服务不可用503错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XMPP和iOS进行文件传输.

I am using XMPP with iOS for file transfer.

我正在使用以下代码行发送文件.但是我一直在遇到一个错误,并一直坚持下去.

I am using following lines of code to send file. But I am continuously getting single error and stuck on issue.

<error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error>

我已经在应用程序中使用以下代码在两个设备之间发送文件.

I have used following code in app to send file between two devices.

XMPPJID *jid = self.chatUserJID;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                                                     NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString* path = [documentsDirectory stringByAppendingPathComponent:
                  @"aqua.png" ];
UIImage* image = [UIImage imageWithContentsOfFile:path];

XMPPSIFileTransfer *sifiletransfer=[[XMPPSIFileTransfer alloc]init];

[sifiletransfer initiateFileTransferTo:jid withData:UIImagePNGRepresentation(image)];
sifiletransfer.sid = [[self xmppStream] generateUUID];

if ([jid.domain isEqualToString:[self.xmppStream myJID].domain]) {
    [TURNSocket setProxyCandidates:[NSArray arrayWithObjects:jid.domain, nil]];
} else {
    [TURNSocket setProxyCandidates:[NSArray arrayWithObjects:jid.domain,[self.xmppStream myJID].domain, nil]];
}
TURNSocket *socket = [[TURNSocket alloc] initWithStream:[[self appDelegate] xmppStream] toJID:jid];;
[socket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];

文件传输日志如下所示.

Log for file transfer is shown as below.

发送:

<iq type="get" to="192.168.2.120" id="596BC614-8653-43CC-925B-E56CFF6DB8CF"><query xmlns="http://jabber.org/protocol/disco#items"/></iq>

RECV:

<iq xmlns="jabber:client" type="result" id="596BC614-8653-43CC-925B-E56CFF6DB8CF" from="192.168.2.120" to="jsojitra@192.168.2.120/4a0ce4e9"><query xmlns="http://jabber.org/protocol/disco#items"><item jid="conference.192.168.2.120" name="Public Chatrooms"/><item jid="pubsub.192.168.2.120" name="Publish-Subscribe service"/><item jid="proxy.192.168.2.120" name="Socks 5 Bytestreams Proxy"/></query></iq>

发送:

<iq type="get" to="proxy.192.168.2.120" id="03078D21-008A-444C-87D4-FCC370D16E5D"><query xmlns="http://jabber.org/protocol/disco#info"/></iq>

RECV:

<iq xmlns="jabber:client" type="result" id="03078D21-008A-444C-87D4-FCC370D16E5D" from="proxy.192.168.2.120" to="jsojitra@192.168.2.120/4a0ce4e9"><query xmlns="http://jabber.org/protocol/disco#info"><identity category="proxy" name="SOCKS5 Bytestreams Service" type="bytestreams"/><feature var="http://jabber.org/protocol/bytestreams"/><feature var="http://jabber.org/protocol/disco#info"/></query></iq>

发送:

<iq type="get" to="proxy.192.168.2.120" id="C537E4CC-AD48-4517-85D7-96D6DF1658F4"><query xmlns="http://jabber.org/protocol/bytestreams"/></iq>

RECV:

<iq xmlns="jabber:client" type="result" id="C537E4CC-AD48-4517-85D7-96D6DF1658F4" from="proxy.192.168.2.120" to="jsojitra@192.168.2.120/4a0ce4e9"><query xmlns="http://jabber.org/protocol/bytestreams"><streamhost jid="proxy.192.168.2.120" host="192.168.2.120" port="7777"/></query></iq>

发送:

<iq type="set" to="spatil@192.168.2.120" id="A791E4C0-3235-402F-A537-94FB296BA0C4"><query xmlns="http://jabber.org/protocol/bytestreams" sid="A791E4C0-3235-402F-A537-94FB296BA0C4" mode="tcp"><streamhost xmlns="http://jabber.org/protocol/bytestreams" jid="proxy.192.168.2.120" host="192.168.2.120" port="7777"/></query></iq>

RECV:

<iq xmlns="jabber:client" type="error" id="A791E4C0-3235-402F-A537-94FB296BA0C4" from="spatil@192.168.2.120" to="jsojitra@192.168.2.120/4a0ce4e9"><query xmlns="http://jabber.org/protocol/bytestreams" sid="A791E4C0-3235-402F-A537-94FB296BA0C4" mode="tcp"><streamhost jid="proxy.192.168.2.120" host="192.168.2.120" port="7777"/></query><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

任何人都可以建议我这个问题可能是什么错误吗?

Can any body please suggest me what can be the mistake because of which this issue is taking place?

我已经完成以下配置以启用文件传输.

I have done following configuration to enable file transfer.

已启用从Openfire进行文件传输. Server -> Server Settings -> File Transfer Settings -> Enable on port number 7777

Enabled file transfer from Openfire. Server -> Server Settings -> File Transfer Settings -> Enable on port number 7777

在Openfire中设置以下服务器属性.

Set following server properties in Openfire.

xmpp.domain             192.168.2.120
xmpp.proxy.enabled      true
xmpp.proxy.externalip   192.168.2.120 / proxy.192.168.2.120 // Tried both
xmpp.proxy.port         7777

如果您有任何想法,我要求您提供帮助.

I request you to help if you have any idea.

提前谢谢!

推荐答案

似乎没有传递带有资源的正确JID. 具有资源的完整JID类似于jsojitra@192.168.2.120/4a0ce4e9. 最后一个特殊的"4a0ce4e9"是应该在JID往返之间的资源.

looks like you haven't passing correct JID with resource. A complete JID with resource looks like jsojitra@192.168.2.120/4a0ce4e9. Last special "4a0ce4e9" are resource which should be in both JID to and from.

您应该拥有

from ="spatil@192.168.2.120/someResourceId"

from="spatil@192.168.2.120/someResourceId"

to ="jsojitra@192.168.2.120/4a0ce4e9

to="jsojitra@192.168.2.120/4a0ce4e9

这篇关于在XMPP中使用iOS进行文件传输时出现服务不可用503错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆