0
votes

im am Developing a Chat app, at the FileTransfers, i can successfully send file to a spark client, but at the listening, i am receiving NullPointerException error at the negotiating part, here is the IQ received by android client from spark:

 RCV (0): <iq id="dnkUY-33" to="reza@reza-hp/Smack" from="admin@reza-hp/Spark 2.6.3"  
 type="set">
 <si xmlns="http://jabber.org/protocol/si" id="jsi_5267323957851897853" 
 mime-type="image/jpeg" profile="http://jabber.org/protocol/si/profile/file-
 transfer">
 <file xmlns="http://jabber.org/protocol/si/profile/file-transfer" 
 name="635px-Food.jpg" size="45135">
 <desc>Sending file</desc>
 </file><feature 
 xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="form">
 <field var="stream-method" type="list-single">
  <option><value>http://jabber.org/protocol/bytestreams</value></option><option>   
  <value>http://jabber.org/protocol/ibb</value></option></field></x></feature> 
  </si></iq>

and here is the error Printed:

   07-01 13:40:49.075: W/System.err(1986): java.lang.NullPointerException
   07-01 13:40:49.075: W/System.err(1986):  
   atorg.jivesoftware.smackx.filetransfer.
   IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:173)
   07-01 13:40:49.075: W/System.err(1986):  at  
   org.jivesoftware.smackx.filetransfer.
   IncomingFileTransfer.access$100(IncomingFileTransfer.java:45)
   07-01 13:40:49.075: W/System.err(1986):  at  
   org.jivesoftware.smackx.filetransfer.
   IncomingFileTransfer$1.run(IncomingFileTransfer.java:122)
   07-01 13:40:49.085: W/System.err(1986):  at java.lang.Thread.run(Thread.java:841)

the Exception is null, but According to the IQ provided, it seems transfer Type is a " Stream Initiation " , so i thought may be asmack doesnt discover it by default, does any one has any solution for this, or knows how to discover "Stream Initiation" ? thanks alot in advance <3 oh and im using OpenFire server :)

1
OOOkkk, just found the solution, i was Right about the problem, am sorry for aSmack's weak IT, just add this field : ServiceDiscoveryManager.getInstanceFor(connection).addFeature("jabber.org/protocol /si"); so your aSmack supports the StreamInitiation.... am sure this Solves alot of ppl's problemsuser3788661
also in some cases you might need to add this to the sending side: FileTransferNegotiator.setServiceEnabled(connection, true); or/and: FileTransferNegotiator.IBB_ONLY=true; //note that this causes to use only IBB protocol, but some times no choice depending on client, server etc, due to asmack k known bugsuser3788661
"just add this field : ServiceDiscoveryManager.getInstanceFor(connection).addFeature("jabber.org/protocol /si");" This is done automatically by aSmack. Also there are "known aSmack bugs" related to file transfer. Which version are you using?Flow
latest version 8-4.0.0, obviously its notuser3788661
and dude, does openfire support offline file transfer?user3788661

1 Answers

0
votes

OOOkkk, just found the solution, i was Right about the problem, am sorry for aSmack's weak IT, just add this field :

 ServiceDiscoveryManager.getInstanceFor(connection).addFeature("jabber.org/protocol  
 /si"); 

so your aSmack supports the StreamInitiation.... am sure this Solves alot of ppl's problems

also add file transfer providers AFTER connection, it makes difference. and by that i mean when ever you are sure they are readen when connection is already connected like "try"

and most important part : use Asmack 8-4.0.0 rc-1 for sure,Best suited for file transfers any questions ill be glad to help, after 1 fckin week trying i think i learnt alot. thanks