【问题标题】:File transfer using XMPP (Extension XEP-0065)使用 XMPP 传输文件(扩展 XEP-0065)
【发布时间】:2012-08-22 15:19:22
【问题描述】:

不知道为什么我会收到转套接字失败(调用了 turnSocketDidFail)。任何人都可以帮我解决这个问题吗?请指出我在这里做错了什么。我知道有很多这样的问题,我已经检查了所有这些问题,并且从中我得到的帮助很少。一个客户端是 Spark,另一个是模拟器。

设置:
服务器:testXyz
发件人吉德:user1@testXyz
接收者jid:user2@testXyz

XMPPJID *jid = [XMPPJID jidWithString:Receiverjid];
[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:Receiverjid, nil]];
TURNSocket *turnSocket = [[TURNSocket alloc] initWithStream:self.chatManager.xmppStream toJID:jid];
[turnSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];

控制台日志

SEND: 
<iq type="get" to="Receiverjid" id="C15C428D-6007-4B4E-96D5-65F7A307121A"><query xmlns="http://jabber.org/protocol/disco#items"/></iq>

RECV:
<iq xmlns="jabber:client" type="result" id="C15C428D-6007-4B4E-96D5-65F7A307121A" from="Receiverjid" to="Senderjid/4840c8ae">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="Receiverjid" node="http://jabber.org/protocol/tune"/>
<item jid="Receiverjid/Spark 2.6.3"/>
</query>
</iq>

SEND: 
<iq type="get" to="Receiverjid" id="A4D8B427-B323-4152-8B19-7B55164E9C4B">
<query xmlns="http://jabber.org/protocol/disco#info"/>
</iq>

RECV: 
<iq xmlns="jabber:client" type="result" id="A4D8B427-B323-4152-8B19-7B55164E9C4B" from="Receiverjid" to="Senderjid/4840c8ae">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="account" type="registered"/>
<identity category="pubsub" type="pep"/>
<feature var="http://jabber.org/protocol/disco#info"/>
</query>
</iq>

SEND: 
<iq type="get" to="Receiverjid/Spark 2.6.3" id="2DE55487-9203-4266-A559-1B1D3DC5FBF4">
<query xmlns="http://jabber.org/protocol/disco#info"/>
</iq>

RECV:
<iq xmlns="jabber:client" id="2DE55487-9203-4266-A559-1B1D3DC5FBF4" to="Senderjid/4840c8ae" type="result" from="Receiverjid/Spark 2.6.3">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="client" name="Smack" type="pc"/>
<feature var="http://www.xmpp.org/extensions/xep-0166.html#ns"/>
<feature var="urn:xmpp:tmp:jingle"/>
</query>
</iq>

RECV:
<iq xmlns="jabber:client" id="2DE55487-9203-4266-A559-1B1D3DC5FBF4" to="Senderjid/4840c8ae" type="result" from="Receiverjid/Spark 2.6.3">
<query xmlns="http://jabber.org/protocol/disco#info">
<identity category="client" name="Smack" type="pc"/>
<feature var="http://jabber.org/protocol/xhtml-im"/>
<feature var="http://jabber.org/protocol/muc"/>
<feature var="http://jabber.org/protocol/bytestreams"/>
<feature var="http://jabber.org/protocol/commands"/>\
<feature var="http://jabber.org/protocol/si/profile/file-transfer"/>
<feature var="http://jabber.org/protocol/si"/>
<feature var="http://jabber.org/protocol/ibb"/>
</query> 
</iq>

更新

如果我要改变:

[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:Receiverjid, nil]];

到:

[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:Server, nil]];

它给了我:

&lt;error code="503" type="cancel"&gt;&lt;service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/&gt;&lt;/error&gt;.

按照解决此错误的堆栈问题之一中的建议,我已将 Receiverjid: 'user2@testXyz' 替换为 'user2@testXyz/spark' 但仍然遇到相同的错误。

【问题讨论】:

  • 据我所知,仅 XEP-0065 无法传输文件,您还需要使用 XEP-0096 来获取会话 ID。传输文件会话 ID 是主要的重要部分。确保文件传输会话的会话 ID 保持不变。

标签: ios xmpp openfire xmppframework


【解决方案1】:

[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:Receiverjid, nil]];在此将“Receiverjid”替换为主机名,例如:sa.com,

【讨论】:

    【解决方案2】:

    iducool,你可以在下面的AppDelegate方法中找到完整的jid资源。

    - (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
    {
        DDLogVerbose(@"%@: %@ - %@", THIS_FILE, THIS_METHOD, [presence fromStr]);
    
      //  NSString *presenceType = [presence type]; // online/offline
        NSString *myUsername = [[sender myJID] user];
        NSString *presenceFromUser = [[presence from] user];
    
        NSLog(@" Printing full jid of user %@",[[sender myJID] full]);
        NSLog(@"Printing full jid of user %@",[[sender myJID] resource]);
        NSLog(@"From user %@",[[presence from] full]);
        senderFullID=[[presence from] full];
    }
    

    【讨论】:

      【解决方案3】:

      不知道在 setProxyCandidates 中设置什么,但我正在设置我的服务器名称。

      &lt;error code="503" type="cancel"&gt;&lt;service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/&gt;&lt;/error&gt;

      解决方案:传递完整的 jabber id:username@domain/resource。 就我而言,我更改了 'user2@testXyz/spark;到 'user2@testXyz/Spark 2.6.3'

      我不知道如何找到这些资源参数。我检查了 XMPPJID 类的资源参数,但它是零。我通过查看一些控制台日志找到了这些参数。如果有人知道如何从任何 xmpp 类中找到它,请告诉我。

      【讨论】:

      • 使用 XEP-0077 InbandReg 传递资源以及 JID 注册到 openfire 服务器时。
      • @lducool 你能解决这个问题吗?如果是,请分享解决方案,因为我也面临同样的问题。
      • 我已经用资源传递了完整的 id,然后我也得到了同样的错误。 jabber.org/protocol/bytestreams" sid="3A4379BB-8AB8-463F-AECE-4A13B8175550" mode="tcp"> 可以请告诉我可能是什么问题?
      猜你喜欢
      • 2012-01-06
      • 2012-07-17
      • 2012-04-29
      • 2012-06-16
      • 2013-08-12
      • 2017-03-13
      • 1970-01-01
      • 1970-01-01
      • 2012-09-02
      相关资源
      最近更新 更多