0

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>

Kingfisher Phuoc
  • 8,052
  • 9
  • 46
  • 86
  • @Flow: If I use `smack.jar` and `smackx.jar` instead of `asmack.jar`, can I solve this problem? – Kingfisher Phuoc Oct 18 '12 at 16:05
  • https://github.com/Flowdalic/asmack/wiki/aSmack-XMPP-File-Transfer – Flow Oct 18 '12 at 21:54
  • @Flow: I edited my question, can you give me a suggestion? – Kingfisher Phuoc Oct 22 '12 at 09:44
  • Thanks you flow! I solved this problem with your new library!! – Kingfisher Phuoc Oct 23 '12 at 07:32
  • You should then answer your question and mark it as answered. Make sure to add all the information needed to solve the problem. – Flow Oct 23 '12 at 08:56
  • @Kingfisher, have you use this blog http://harryjoy.com/2012/08/18/file-transfer-in-android-with-asmack-and-openfire/ to send file ? and which smack lib you finally using ? – Abdul Wahab Aug 07 '14 at 06:11
  • @Kingfisher if you got solution than you can help me, my chat app with ejabberd server and between android clients working properly but when i send any file than the progress of sending stucks at 0.0..what could be the reason? – Devang Sep 09 '14 at 15:33
  • @Devang You should use newest version of `asmack`, and config Ejabberd server to support file transfer – Kingfisher Phuoc Sep 10 '14 at 02:58

0 Answers0