title: service-unavailable 503 error for file transfer in XMPP with iOS
body: <p>I am using XMPP with iOS for file transfer.</p>
  
  <p>I am using following lines of code to send file. But I am continuously getting single error and stuck on issue. </p>
  
  <p><code>&lt;error code="503" type="cancel"&gt;&lt;service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/&gt;&lt;/error&gt;</code></p>
  
  <p>I have used following code in app to send file between two devices.</p>
  
  <pre><code>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()];
  </code></pre>
  
  <p>Log for file transfer is shown as below.</p>
  
  <p>SEND: </p>
  
  <pre><code>&lt;iq type="get" to="192.168.2.120" id="596BC614-8653-43CC-925B-E56CFF6DB8CF"&gt;&lt;query xmlns="http://jabber.org/protocol/disco#items"/&gt;&lt;/iq&gt;
  </code></pre>
  
  <p>RECV: </p>
  
  <pre><code>&lt;iq xmlns="jabber:client" type="result" id="596BC614-8653-43CC-925B-E56CFF6DB8CF" from="192.168.2.120" to="jsojitra@192.168.2.120/4a0ce4e9"&gt;&lt;query xmlns="http://jabber.org/protocol/disco#items"&gt;&lt;item jid="conference.192.168.2.120" name="Public Chatrooms"/&gt;&lt;item jid="pubsub.192.168.2.120" name="Publish-Subscribe service"/&gt;&lt;item jid="proxy.192.168.2.120" name="Socks 5 Bytestreams Proxy"/&gt;&lt;/query&gt;&lt;/iq&gt;
  </code></pre>
  
  <p>SEND: </p>
  
  <pre><code>&lt;iq type="get" to="proxy.192.168.2.120" id="03078D21-008A-444C-87D4-FCC370D16E5D"&gt;&lt;query xmlns="http://jabber.org/protocol/disco#info"/&gt;&lt;/iq&gt;
  </code></pre>
  
  <p>RECV: </p>
  
  <pre><code>&lt;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"&gt;&lt;query xmlns="http://jabber.org/protocol/disco#info"&gt;&lt;identity category="proxy" name="SOCKS5 Bytestreams Service" type="bytestreams"/&gt;&lt;feature var="http://jabber.org/protocol/bytestreams"/&gt;&lt;feature var="http://jabber.org/protocol/disco#info"/&gt;&lt;/query&gt;&lt;/iq&gt;
  </code></pre>
  
  <p>SEND: </p>
  
  <pre><code>&lt;iq type="get" to="proxy.192.168.2.120" id="C537E4CC-AD48-4517-85D7-96D6DF1658F4"&gt;&lt;query xmlns="http://jabber.org/protocol/bytestreams"/&gt;&lt;/iq&gt;
  </code></pre>
  
  <p>RECV: </p>
  
  <pre><code>&lt;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"&gt;&lt;query xmlns="http://jabber.org/protocol/bytestreams"&gt;&lt;streamhost jid="proxy.192.168.2.120" host="192.168.2.120" port="7777"/&gt;&lt;/query&gt;&lt;/iq&gt;
  </code></pre>
  
  <p>SEND: </p>
  
  <pre><code>&lt;iq type="set" to="spatil@192.168.2.120" id="A791E4C0-3235-402F-A537-94FB296BA0C4"&gt;&lt;query xmlns="http://jabber.org/protocol/bytestreams" sid="A791E4C0-3235-402F-A537-94FB296BA0C4" mode="tcp"&gt;&lt;streamhost xmlns="http://jabber.org/protocol/bytestreams" jid="proxy.192.168.2.120" host="192.168.2.120" port="7777"/&gt;&lt;/query&gt;&lt;/iq&gt;
  </code></pre>
  
  <p>RECV: </p>
  
  <pre><code>&lt;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"&gt;&lt;query xmlns="http://jabber.org/protocol/bytestreams" sid="A791E4C0-3235-402F-A537-94FB296BA0C4" mode="tcp"&gt;&lt;streamhost jid="proxy.192.168.2.120" host="192.168.2.120" port="7777"/&gt;&lt;/query&gt;&lt;error code="503" type="cancel"&gt;&lt;service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/&gt;&lt;/error&gt;&lt;/iq&gt;
  </code></pre>
  
  <p>Can any body please suggest me what can be the mistake because of which this issue is taking place?</p>
  
  <p>I have done following configuration to enable file transfer.</p>
  
  <p>Enabled file transfer from Openfire.
  <code>Server -&gt; Server Settings -&gt; File Transfer Settings -&gt; Enable on port number 7777</code></p>
  
  <p>Set following server properties in Openfire.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I request you to help if you have any idea.</p>
  
  <p>Thanks in advance!!!</p>