4

I'm using Openfire server (3.7.1) for XMPP authentication, messaging and file transfer. I'm using iOS's XMPPFramework to communicate with it.

I've successfully established authentication, sending and receiving presence, sending and receiving messages. However when I tried to use file transfer, I wasn't able to accomplish.

Please take a look at my code below.

For the sender:

NSArray *proxyList = [NSArray arrayWithObjects:self.hostname,nil];
[TURNSocket setProxyCandidates:proxyList];
TURNSocket *fileTransferSocket = [[TURNSocket alloc] initWithStream:self.xmppStream toJID:userJid];
if (fileTransferSocket) {
    [fileTransferSocket startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
}

For the receiver:

- (BOOL)xmppStream:(XMPPStream*)sender didReceiveIQ:(XMPPIQ *)iq {

    if ([TURNSocket isNewStartTURNRequest:iq]) {
        TURNSocket *receiverSock = [[TURNSocket alloc] initWithStream:self.xmppStream incomingTURNRequest:iq];
        [self.turnSockets addObject:receiverSock];
        [receiverSock startWithDelegate:self delegateQueue:dispatch_get_main_queue()];
    }
    return YES;
}

Also implemented the delegate methods of TURNSocket:

- (void)turnSocket:(TURNSocket *)sender didSucceed:(GCDAsyncSocket *)socket  {
    NSLog(@"Socket Suceeed Port For File Transfer: %d",socket.localPort);

    if ([self.turnSockets containsObject:sender]) {
        NSLog(@"File Transfer Ulastiiiiiiii");
        NSUInteger indexOfObj = [self.turnSockets indexOfObject:sender];
        [self.turnSockets removeObjectAtIndex:indexOfObj];
    }
}

But when I try to start file transferring process, I receive an error like this:

<query xmlns="http://jabber.org/protocol/bytestreams" sid="99DC0DA7-55ED-4A53-9A8F-F65F1706E1B2" mode="tcp">
<streamhost jid="proxy.192.168.12.30" host="192.168.12.30" port="7777"/>
</query>
<error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
</error>
</iq>

I don't understand what the problem might be.

The only thing that came to my mind is that I'm not using SSL authentication while connecting to server. Could it be the reason or is it something else I'm missing?

Thanks.

Keith OYS
  • 2,285
  • 5
  • 32
  • 38
tolgatanriverdi
  • 561
  • 9
  • 31
  • 3
    I've found the problem about error 503 its because I was not appending resource tag to JID (instead tolga@mydomain/f48sasd I was just sending tolga@mydomain). Now I'm not receiving erro 503 service not available but this time I've started to receive below error and I couldn't find the problem. Does anyone have any idea about that? Thanks – tolgatanriverdi Jan 23 '12 at 11:51
  • Hi. Did you get this to work? I have a similar issue to your original problem, but I don't think I'm missing the resource tag. http://stackoverflow.com/questions/10205758/openfire-503-service-unavailable-error-using-ios-xmppframework – Andy A Apr 18 '12 at 08:56
  • Infact, as I continue my research, maybe i also just need to append the resource tag to the JID. I'm just struggling to see where to do this in my code. Did you base your code on this tutorial ... http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/ ? – Andy A Apr 18 '12 at 11:42
  • Hey can you tell me how to get resource? – Sunil Zalavadiya Feb 20 '13 at 11:19

1 Answers1

1

in XMPP - presence delegate

use : [self from] full], will full JID with resource.

1) [self from]user], gives only Username@domain 2) [self from] full], gives full JID as below

JID : username@domain/resourceid

hope, above information will help