File transfer using XMPP (Extension XEP-0065)

匿名 (未验证) 提交于 2019-12-03 08:30:34

问题:

Not sure why I am getting turn socket failed (turnSocketDidFail called). Anybody can help me in figure out this? Please point me what am I doing wrong here. I know there are lots of question like this and I have already checked all of these and from that I have taken little help already. One of client is Spark and other is simulator.

Settings:
Server: 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()]; 

Console logs

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> 

Update

If I am changing:

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

to:

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

It gives me:

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

As suggested in one of question on stack to resolve this error I have replaced Receiverjid: 'user2@testXyz' by 'user2@testXyz/spark' but am still getting same error.

回答1:

[TURNSocket setProxyCandidates:[NSArray arrayWithObjects:Receiverjid, nil]]; In this replace "Receiverjid" with hostname, eg:sa.com,



回答2:

iducool ,you can find full jid with resource in following method of AppDelegate.

- (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:

Don't know what to set in setProxyCandidates, but I am setting my Server name.

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

Solution: Pass full jabber id:username@domain/resource. In my case I have changed 'user2@testXyz/spark; to 'user2@testXyz/Spark 2.6.3'

I don't know how to find these resource parameters. I have checked XMPPJID class's resource parameter but it is nil. I found these parameters by seeing some console logs. If anybody know how to find this from any xmpp class then please let me know.



回答4:

EDIT : Put the file to a WebDAV server and send the URL over XMPP, using XEP-0065. For further questions refer this



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!