This is how I try to send a file over XMPP using asmack
lib (from the GtalkSms project) and a Ejabberd server:
//Configure provider in onCreate()
configure(ProviderManager.getInstance());
// Configure function
private void configure(ProviderManager pm){
pm.addIQProvider("si","http://jabber.org/protocol/si", new StreamInitiationProvider());
pm.addIQProvider("query","http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
pm.addIQProvider("open","http://jabber.org/protocol/ibb", new OpenIQProvider());
pm.addIQProvider("close","http://jabber.org/protocol/ibb", new CloseIQProvider());
pm.addExtensionProvider("data","http://jabber.org/protocol/ibb", new DataPacketProvider());
}
// This is how I send file after login to server (I put everything below in a
function, inside a Thread and call thread.start() at the end of function):
// set the serviceDiscoveryManager
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(xmppConn);
if (sdm == null){
sdm = new ServiceDiscoveryManager(xmppConn);
}
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
// Create the file transfer manager
FileTransferManager manager = new FileTransferManager(connection);
FileTransferNegotiator.setServiceEnabled(connection, true);
OutgoingFileTransfer transfer = manager
.createOutgoingFileTransfer(Receiver
+ "@MyDomain");
transfer.sendFile(new File(myFilePath), "myDescription");
If I use another client to test the file transfer (http://coccinella.im/), then I can chat and send a file over my Ejarbberd server between (2 coccinella clients). If I use a coccinella client and my client in android, I can chat between them and I can receive file sent from coccinella client to my android client. However, when I try to send file from my android client to the coccinella client, transfer.isDone()
always returns true
and transfer.getStatus() == Status.error
also returns true
.
So what's happen to my Android client? Did I use wrong library? Or I missed something?
Edited: This is what I got from debugger: <iq id="QgJIb-29" to="phuocdh@localhost/Smack" from="phuoctest@localhost/Coccinella@phuocdh-pc" type="error"><error code="404" type="CANCEL"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><query xmlns="http://jabber.org/protocol/bytestreams"><streamhost></streamhost></query></error></iq>