Q: FileTransfer: How to determine Ressource

Hi everybody!

I have problems to implement the file transfer to my little chat application I’m writting on base of the SMACK API.

I decided to not bother about the exact jid of my friends (name@host.com/RESSOURCE) and only take care of the Bare Adress (name@host.com) to identfy an user internal and display the chat messages in my program.

Now i wanted to implement a very simple FileTranfser-Feature and I came into the following problem:

I’m trying to send a file to a friend in the roster really straight forward like shown in the documentation:

OutgoingFileTransfer transfer = mFileTransferManager.createOutgoingFileTransfer(jidToSend);
transfer.sendFile(file, jid);

File is an instance of java.io.File and JID is a String with value e.x "test@jabber.org".

If i try to start a transfer with the user given without the ressource I imediatelly receive an error packet

<iq id="7VR8D-9" to="test@jabber.org" from="xxx@jabber.org" type="error">
  <error code="503" type="CANCEL">
    <service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
  </error>
</iq>

I found that adding a ressource to the jid solves my problems. I tried this with some hardcoded values and jid-strings.

But i did not found a way to determine the ressource(s) of a given user via the smack api or by the roster. How can I find them out?

One of my ideas was to create chats for all entries in the connections roster after successfull connect and login. But in the Chat-Objects the returned participants are also the bare jid adress.

What can I do?

Thanks in advance for your help

Stefan

Hello again!

When i entered the tags for my initial question i figured out some other usefull search terms (btw. you are using a great forum software) and so i found this post in the archives:

Chris Ward advices to use the Presence of a user to determine the exact ressource. Thank you very much I didn’t see this possability.

thx