title: OpenFire/XMPP 503 service-unavailable error (XEP-0065 using iOS XMPPFramework)
body: <p><strong>Problem</strong> : I am attempting a TURN Connection (XEP-0065) using the iOS XMPPFramework and an OpenFire Server. I want to be able to send and receive files. However, I am receiving a 503 service-unavailable error.</p>
  
  <p><strong>Note</strong> : The base of my code is from the following tutorial : <a href="http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/" rel="nofollow">http://mobile.tutsplus.com/tutorials/iphone/building-a-jabber-client-for-ios-server-setup/</a></p>
  
  <p><strong>XML Error</strong> :</p>
  
  <p>I've debugged through TURNSocket.m. It goes into processRequestResponse and has the following XML. (If I am not mistaken, this has been sent from OpenFire to me, rather than vice versa?) ...</p>
  
  <pre><code>&lt;iq xmlns="jabber:client"
      type="error" 
      id="03CC977E-2645-4E87-AE78-536D985CA2B5" 
      from="friendsUsername@beta.myCompany.co.uk"
      to="myUsername@beta.myCompany.co.uk/12f10b69"&gt;
      &lt;query xmlns="http://jabber.org/protocol/bytestreams" 
          sid="03CC977E-2645-4E87-AE78-536D985CA2B5"
          mode="tcp"&gt;
          &lt;streamhost jid="proxy.beta.myCompany.co.uk"
              host="127.0.1.1"
              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>Why is there an error?</p>
  
  <p><strong>Update</strong> : <a href="http://xmpp.org/extensions/xep-0065.html" rel="nofollow">XEP-0065</a> says the following. Even though this error looks a little different to mine, is it relevant? If so, what is the problem?</p>
  
  <blockquote>
    <p>If the Proxy is unable to act as a StreamHost, the Proxy MUST return
    an error to the Requester, which SHOULD be <code>&lt;not-allowed/&gt;</code>.</p>
  
  <pre><code>&lt;iq from='requester@example.com/foo'
      id='uj2c15z9'
      to='streamer.example.com'
      type='error'&gt;
    &lt;error type='cancel'&gt;
      &lt;not-allowed 
          xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/&gt;
    &lt;/error&gt;
  &lt;/iq&gt;
  </code></pre>
  </blockquote>
  
  <p><strong>Update</strong> : At the moment I'm looking into whether the inclusion or exclusion of a JID resource in the various sent and retrieved bits of XML is the problem. Or alternatively, I don't even have a 'from' in the following xml. the docs imply i need this. Is this the issue? I dont see a current way in the code to make a 'from' ...</p>
  
  <pre><code>&lt;iq type="get" 
      to="beta.myCompany.co.uk"
      id="215784CF-81A8-403E-89BF-455C926BEAE5"&gt;
      &lt;query xmlns="http://jabber.org/protocol/disco#items"/&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p><strong>Update 19/04/12 11:00 am</strong> : In response to Matt J's response, I am posting more XML. I'm not sure Matt requested the full XML log of what is sent and retrieved, but just in case, here it is. Note that these logs are not all from the same run-through (because when I debug it to get the XML logs, it causes timeouts so I have to start again)</p>
  
  <p><em>Sent</em> :</p>
  
  <pre><code>&lt;iq type="get" to="beta.myCompany.co.uk" 
      id="082A1987-384F-43CD-9E7B-A2C0E31F2CA8"&gt;
      &lt;query xmlns="http://jabber.org/protocol/disco#items"/&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p><em>Response</em> :</p>
  
  <pre><code>&lt;iq xmlns="jabber:client" 
      type="result" 
      id="18EED477-B0E4-492D-89CF-CA692FCF13AD"
      from="beta.myCompany.co.uk" 
      to="myUsername@beta.myCompany.co.uk/72d23cd0"&gt;
      &lt;query xmlns="http://jabber.org/protocol/disco#items"&gt;
          &lt;item jid="pubsub.beta.myCompany.co.uk" 
              name="Publish-Subscribe service"/&gt;
          &lt;item jid="broadcast.beta.myCompany.co.uk" 
              name="Broadcast service"/&gt;
          &lt;item jid="search.beta.myCompany.co.uk" 
              name="User Search"/&gt;
          &lt;item jid="conference.beta.myCompany.co.uk" 
              name="Public Chatrooms"/&gt;
          &lt;item jid="proxy.beta.myCompany.co.uk" 
              name="Socks 5 Bytestreams Proxy"/&gt;
      &lt;/query&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p><em>Sent</em> :</p>
  
  <pre><code>&lt;iq type="get" 
      to="proxy.beta.myCompany.co.uk" 
      id="F1B5370C-234F-4F2D-93E7-D60D2C35D063"&gt;
      &lt;query xmlns="http://jabber.org/protocol/disco#info"/&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p><em>Response</em> :</p>
  
  <pre><code>&lt;iq xmlns="jabber:client" 
      type="result" 
      id="F1B5370C-234F-4F2D-93E7-D60D2C35D063"
      from="proxy.beta.myCompany.co.uk" 
      to="myUsername@beta.myCompany.co.uk/32276f6"&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><em>Sent</em> :</p>
  
  <pre><code>&lt;iq type="get" 
      to="proxy.beta.myCompany.co.uk" 
      id="84904B7D-2BB2-4B8E-90BE-BE0F5A934764"&gt;
      &lt;query xmlns="http://jabber.org/protocol/bytestreams"/&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p><em>Response</em> :</p>
  
  <pre><code>&lt;iq xmlns="jabber:client" 
      type="result" 
      id="B412512B-FA27-4531-88BE-2FC0A26E6ED2"
      from="proxy.beta.myCompany.co.uk" 
      to="myUsername@beta.myCompany.co.uk/45ca808d"&gt;
      &lt;query xmlns="http://jabber.org/protocol/bytestreams"/&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p>plus we also get a streamhost from the code from the query like this: <code>NSXMLElement *streamhost = [query elementForName:@"streamhost"];</code></p>
  
  <pre><code>&lt;streamhost xmlns="http://jabber.org/protocol/bytestreams"
      jid="proxy.beta.myCompany.co.uk"
      host="127.0.1.1" 
      port="7777"/&gt;
  </code></pre>
  
  <p><em>Sent</em> :</p>
  
  <pre><code>&lt;iq type="set" 
      to="friendsUsername@beta.myCompany.co.uk/spark" 
      id="DD96A581-BFA3-47BC-A3C0-D26AD48D7442"&gt;
      &lt;query xmlns="http://jabber.org/protocol/bytestreams" 
          sid="DD96A581-BFA3-47BC-A3C0-D26AD48D7442" 
          mode="tcp"&gt;
          &lt;streamhost xmlns="http://jabber.org/protocol/bytestreams"
              jid="proxy.beta.myCompany.co.uk" 
              host="127.0.1.1"
              port="7777"/&gt;
      &lt;/query&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p>This gives no response, but it looks ok to me when I compare to example 17 of <a href="http://xmpp.org/extensions/xep-0065.html" rel="nofollow">XEP-0065</a>. HOWEVER, if don't include a resource on the jID passed into TurnSocket.m (friendsUsername@beta.myCompany.co.uk rather than friendsUsername@beta.myCompany.co.uk/spark), then this send request changes appropriately</p>
  
  <pre><code>&lt;iq type="set"
       to="friendsUsername@beta.myCompany.co.uk" **LOOK! NO RESOURCE!**
       id="5D08B85E-CA78-4AA8-A893-C1DC571A9808"&gt;
       &lt;query xmlns="http://jabber.org/protocol/bytestreams" 
          sid="5D08B85E-CA78-4AA8-A893-C1DC571A9808" 
          mode="tcp"&gt;
          &lt;streamhost xmlns="http://jabber.org/protocol/bytestreams"
              jid="proxy.beta.myCompany.co.uk"
              host="127.0.1.1"
              port="7777"/&gt;
        &lt;/query&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p>and the XML in my original question above is returned! (with the 503 error code). Furthermore, I notice that this xml contains 'streamhost', but at this stage should it actually contain 'streamhost-used'? Why is there an error? Should or shouldn't I include the resource in the 'to'?</p>
  
  <p><strong>Minor Update 19/04/2012 15:07</strong> : I have added xmpp.proxy.transfer.required as false on OpenFire. This is due to these discussions: <a href="http://code.google.com/p/xmppframework/issues/detail?id=77" rel="nofollow">here</a> and <a href="http://community.igniterealtime.org/thread/28006" rel="nofollow">here</a>. I didn't set up this server (my colleague did) and I don't understand what it means, but it doesn't seem to have made any difference to my problem.</p>
  
  <p><strong>Update 20/04/2012 10:00</strong> : My 503 error I think is correctly there when I don't include the resource (according to <a href="http://community.igniterealtime.org/thread/39043;jsessionid=FE85F011C80140AF447447DA198847E8?tstart=436" rel="nofollow">this</a>). Even if this is so though, I'm unsure why I get no response with a full jID.</p>