我不知道为什么我的转换套接字失败(调用了turnSocketDidFail)。任何人都可以帮我解决这个问题?请指出我在这里做错了什么。我知道有很多这样的问题,我已经检查了所有这些,并且从那以后我已经收到了一些帮助。客户端之一是Spark,其他是模拟器。
设置:
服务器:testXyz
Senderjid:user1 @ testXyz
Receiverjid: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]];
它给了我:
<error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error>
。
正如在堆栈上的一个问题中建议的那样,我已经用'user2 @ testXyz / spark'替换了Receiverjid:'user2 @ testXyz',但仍然会出现同样的错误。
答案 0 :(得分:0)
不知道在setProxyCandidates中设置什么,但我正在设置我的服务器名称。
<error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error>
解决方案:传递完整的jabber ID: username @ domain / resource。 在我的情况下,我改变了'user2 @ testXyz / spark;到'user2 @ testXyz / Spark 2.6.3'
我不知道如何找到这些资源参数。我检查了XMPPJID类的资源参数,但它是nil。我通过查看一些控制台日志找到了这些参数。如果有人知道如何从任何xmpp类中找到这个,请告诉我。
答案 1 :(得分:0)
[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:Receiverjid,nil]];在此替换&#34; Receiverjid&#34;使用主机名,例如:sa.com,
答案 2 :(得分:0)
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 :(得分:-1)
编辑:将文件放入WebDAV服务器,并使用XEP-0065通过XMPP发送URL。 有关更多问题,请参阅this