powered by Jive Software

Problem sending file with filetransfer

Hi I’m just playing around with smack and testing it out for future apps and I have run into a problem sending a file from one user to another. my code is below.

+import org.jivesoftware.smack.*;+

+import org.jivesoftware.smack.packet.Message;+

+import java.io.*;+

+import org.jivesoftware.smackx.filetransfer.*;+

public class RsUfClient


public RsUfClient()



public static void main (String[] args) {

XMPPConnection connection = new XMPPConnection(“gmail.com”);




*connection.login("rsuftesting@gmail.com", "


Chat chat = connection.getChatManager().createChat("chrisishere@gmail.com", new MessageListener() {

public void processMessage(Chat chat, Message message) {

*System.out.println("Received message: " * message);+





catch (Exception e) {



// Create the file transfer manager

FileTransferManager manager = new FileTransferManager(connection);

  •      System.out.println("working so far");+

// Create the outgoing file transfer

OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer("chrisishere@gmail.com");

  •      +

// Send the file



transfer.sendFile(new File(“blah.txt”), “You won’t believe this!”);

}catch (Exception e)





everything compiles properly but when ran, it gets the following error: Exception in thread “main” java.lang.IllegalArgumentException: The provided user id was not fully qualified. It is having problems with the jabber id: chrisishere@gmail.com but not sure why. Ive tried other usernames and same problem so I can only assume my code is having issues. anyone know the reason? much help is appreciated, thanks


You need to specify a fully qualified JID. A fully qualified JID includes a resource value.

For example: bill.smith@jabber.com/Spark


So thank you that solved that error that I was getting. I was trying to send it to a person using Adium so the full jid was chrisishere@gmail.com/Adium. But it is still not sending the file. I try monitoring the process and it gets to the Negotiating transfer status and then errors out. But I can never find out what the error is because it says null when I check. Also I get compiling errors for

+if(transfer.getStatus().equals(Status.ERROR)) {+

+System.out.println("ERROR!!! " + transfer.getError());+


it says that* Status.ERROR cannot find symbol*. I couldnt figure out how to fix it.

UPDATE: I think i found out the error. I do transfer.getError() and transfer.getException() and while getError() just gives a null value, the exception given is “service-unavailable(503)”. ANyone know how to resolve this? I’m using gmail.com as my server.

I think (503) service unavailable means the server you are using does not support the implementation of the feature you are trying to use. So for example, the server may support file transfer, but it may not be using the same specification or version of the specification that Smack has implemented. I am using Openfire, and file transfer is working with Smack in that case for me. So you need to determine if both Smack and the server are using the same thing.


Ok so thank you for replying. A few questions I have though:

How do i determine (codewise) if they have the same specification of file transfer?

If I can’t use gmail as a server. is there any other open servers that support Smack’s file transfer version, without me having to create my own server?

Ive been trying other servers, but half the time I get an SASL authentication failed error…what is causing this and what code do i need to implement in order to resolve this?

It would be great if I can get these questions answered, as I am new to smack and don’t quite understand all the limitations and don’t have specific examples to work with. thanks!

Well, Smack already determines whether it is compatible with the server using a service discovery protocol extension, hence the “service unavailable” error (I think). There could be another reason for the error too as I don’t have a lot of experience with that. The file transfer implementation is based on XEP-0096. So you need to see if Google uses that XEP and even if they do, it is possible there are deviations in Smack or Google that could cause it to not work. Every feature beyond the basic chat and presence in the XMPP protocol is specified by a XEP, which Smack implements a few of them. Here is a list of the Smack Extensions and a link to the corresponding XEP.

The other servers you are trying must not support secure authentication (SASL), you can tell Smack not to do that using the ConnectionConfiguration#setSASLAuthenticationEnabled method.

Finally, the server hosted here (igniterealtime.org) is running Openfire and allows you to create an account so that should work for you if nothing else.


Ok im trying to use igniterealtime.org now. To register a jid, I just used adium and it registered it within that client. I also disable SASL but am still getting an error not-authorized(401). this is my code to connect:

ConnectionConfiguration config = new ConnectionConfiguration(“igniterealtime.org”);


XMPPConnection connection = new XMPPConnection(config);


connection.login("rsuftesting@igniterealtime.org", “*******”);

is this correct? what else should i add/edit? I think im getting closer to getting file transfer to work thanks

I think for the igniterealtime.org server you want to leave SASL authentication turned on and you should only use the username to login, not the full JID with the domain.


part of the problems was that neither Adium (Mac os x) or Pidgin(PC) could successfully register an igniterealtime.org jid. I kept getting a 400 bad request error. So i had to download spark and register it through that. Thanks for the help!