service-unavailable 503 error for file transfer in XMPP with iOS

I am using XMPP with iOS for file transfer.

I am using following lines of code to send file. But I am continuously getting single error and stuck on issue.

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

I have used following code in app to send file between two devices.

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

Log for file transfer is shown as below.


<iq type="get" to="" id="596BC614-8653-43CC-925B-E56CFF6DB8CF"><query xmlns=""/></iq>


<iq xmlns="jabber:client" type="result" id="596BC614-8653-43CC-925B-E56CFF6DB8CF" from="" to="jsojitra@"><query xmlns=""><item jid="conference." name="Public Chatrooms"/><item jid="pubsub." name="Publish-Subscribe service"/><item jid="proxy." name="Socks 5 Bytestreams Proxy"/></query></iq>


<iq type="get" to="proxy." id="03078D21-008A-444C-87D4-FCC370D16E5D"><query xmlns=""/></iq>


<iq xmlns="jabber:client" type="result" id="03078D21-008A-444C-87D4-FCC370D16E5D" from="proxy." to="jsojitra@"><query xmlns=""><identity category="proxy" name="SOCKS5 Bytestreams Service" type="bytestreams"/><feature var=""/><feature var=""/></query></iq>


<iq type="get" to="proxy." id="C537E4CC-AD48-4517-85D7-96D6DF1658F4"><query xmlns=""/></iq>


<iq xmlns="jabber:client" type="result" id="C537E4CC-AD48-4517-85D7-96D6DF1658F4" from="proxy." to="jsojitra@"><query xmlns=""><streamhost jid="proxy." host="" port="7777"/></query></iq>


<iq type="set" to="spatil@" id="A791E4C0-3235-402F-A537-94FB296BA0C4"><query xmlns="" sid="A791E4C0-3235-402F-A537-94FB296BA0C4" mode="tcp"><streamhost xmlns="" jid="proxy." host="" port="7777"/></query></iq>


<iq xmlns="jabber:client" type="error" id="A791E4C0-3235-402F-A537-94FB296BA0C4" from="spatil@" to="jsojitra@"><query xmlns="" sid="A791E4C0-3235-402F-A537-94FB296BA0C4" mode="tcp"><streamhost jid="proxy." host="" port="7777"/></query><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

Can any body please suggest me what can be the mistake because of which this issue is taking place?

I have done following configuration to enable file transfer.

Enabled file transfer from Openfire. Server -> Server Settings -> File Transfer Settings -> Enable on port number 7777

Set following server properties in Openfire.

xmpp.proxy.enabled      true
xmpp.proxy.externalip / proxy. // Tried both
xmpp.proxy.port         7777

I request you to help if you have any idea.

Thanks in advance!!!

looks like you haven't passing correct JID with resource. A complete JID with resource looks like jsojitra@ Last special "4a0ce4e9" are resource which should be in both JID to and from.

You should have



service-unavailable 503 error for transferring files to XMPP with iOS, It looks like you did not pass the correct JID with the resource. The full JID with the resource looks like jsojitra@ The last special  Ошибка 503 было связано с тем, что я не обеспечивающей полный JID. например, я предоставлял friendsUsername @ домен, а не friendsUsername @ домен / ресурс.

You can use file transfer extension for sending file. You can refer XMPP File Transfer Demo on GitHub. There is also sample application for file transfer using it.

Code=503 service-unavailable ,I can't send the file,please help , Code=503 service-unavailable ,I can't send the file,please help! /26250533/​service-unavailable-503-error-for-file-transfer-in-xmpp-with-ios. A 503 Service Unavailable Error indicates that a web server is temporarily unable to handle a request. That could be the web server you’re trying to access directly, or another server that web server is in turn trying to access.

I had same problem, I investigated the stanza and solved it this way.

Many people use "/Smack" or "/Resource" as resource part in jid, that is not wrong but you can set resource another way.

Like Arpan Dixit explained, resource path is changing with every presence changed of user. Lets say we want to send image to this user: "user1@mydomain"

You must add "/Resource" part to this jid and it become this: user1@mydomain/Resource

But /Resource path is changing with presence so you must follow every presence change to update resource path. Best way is to get user presence is in roster listener and in presencheChanged() method you get last user resource part like this:

Roster roster=getRoster();
roster.addRosterListener(new RosterListener() {
                public void entriesAdded(Collection<Jid> addresses) {
                    Log.d("entriesAdded", "ug");
                    context.sendBroadcast(new Intent("ENTRIES_ADDED"));

                public void entriesUpdated(Collection<Jid> addresses) {
                    Log.d("entriesUpdated", "ug");

                public void entriesDeleted(Collection<Jid> addresses) {
                    Log.d("entriesDeleted", "ug");

                public void presenceChanged(Presence presence) {
                    Log.d("presenceChanged", "ug");
                    //Resource from presence
                    String resource = presence.getFrom().getResourceOrEmpty().toString();
                    //Update resource part for user in DB or preferences

Resource string will be some generated string like "6u1613j3kv" and jid will become:


That means that you must create your outgoing transfer like this:

EntityFullJid jid = JidCreate.entityFullFrom("user1@mydomain/6u1613j3kv"); 
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(jid)
transfer.sendFile(new File("DirectoryPath"), "Description");

Ofcourse this code is example from Android but it is same for your application on iOS.

Also this can be configured the easy way, just set the resource on

XMPPTCPConnectionConfiguration.Builder //android example.


XMPPTCPConnectionConfiguration.Builder configurationBuilder = 


Why XMPPOutgoingFileTransfer fails when other user is offline?, But when any one user go to offline then it fails to send file data and following *)error And the error is Error Domain=XMPPOutgoingFileTransferErrorDomain Code=503 "<service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>​"  As far as I know (503) service unavailable means the server you are using does not support the implementation of the feature you are trying to use. Check and verify that your smack and server are using same version of specification for file transfer.

My program worked fine at first, and the same problem occured later. My problem is that the offline message capacity exceeds the preset value in my openfire server. I check my openfire server,and in "Server Settings" I find an item called "offline messaging policy",I expanded the offline message storage capacity of single user. Then the app works fine.

frenchie4111/xmpp-chat-server, @dilipsoni1986. How to transfer files from device to device with XMPPFramework in ios? I am using <error code="503" type="cancel"><service-unavailable  5.2 <file/> Element¶. The <file/> element is the "workhorse" element. This element is used to convey metadata and report file transfer actions. This elemnt contains attributes for file metadata and actions, and MAY contain a <desc/>, a <range/>, and zero or more <feature xmlns='jabber:iq:negotiate'/> (Feature Negotiation (XEP-0020) []) elements.

System Error Messages for Cisco Unified Communications Manager , Explanation The ANN background TFTP file transfer processing thread failed to The XCP Connection Manager service has errors in the XMPP interface. Remote=503 ("503 Service Unavailable" a standard SIP RFC error code), Recommended Action RSVP Agents are basically Cisco IOS MTPs or  If nothing happens, download GitHub Desktop and try again. This application is merely a brief demo of how to use the file transfer extension of the XMPPFramework. A detailed blog post can be found here. My changes have been merged into the master branch of the XMPPFramework, so you'll want to

Error code 503 on transferring file using xmpp, I am trying to send an image file using smack and openfire xmpp. Error code 503 on transferring file using xmpp Log.e("service discovery", "SDM"); ></​feature></si><error code="503" type="cancel"><service-unavailable  This specification defines a Jingle application type for transferring a file from one entity to another. The protocol provides a modular framework that enables the exchange of information about the file to be transferred as well as the negotiation of parameters such as the transport to be used.

Tunnel connection failed: 503 Service Unavailable Ejabberd , XMPPFramework - Keep Receiving Error Code 503 Service Unavailable. I'm using Openfire server (3.7.1) for XMPP authentication, messaging and file transfer. Appendix D: Relation to XMPP¶. The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026.

  • Hey Man! looks like you haven't passing correct JID with resource.A complete JID with resource looks like jsojitra@
  • I have tried using full resource id in from and to also but still there are some issue and showing same error.
  • I have uploaded latest code on following link can you please check it out? If we can solve the problem
  • Okay.Buddy let me check that.
  • Hey!Jayesh I sending you my app delegate.i have modified app delegate according to my use to transfer image.I have merged XMPPSIFiletranfer all methods in my app delegate. Just pass data in follwing mathod -(void)sendToOtherDevice:(NSData )fileData receiverJid:(NSString *)receiverJid file:(NSString *)fileName and handle delegate methods of XMPPSiFiletranfer in appdelegate - (void)receivedImage:(NSData)image from:(XMPPJID*)from{
  • Get appDelegates file from here