本文介绍了aSmack文件传输返回NPE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯正在开发一个聊天应用程序,在FileTransfers,我可以成功地发送文件到火花的客户端,但在听,我收到NullPointerException异常错误在谈判的一部分,这里是火花收到Android客户端的智商:

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>

和以下是错误的打印:

   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)

唯一的例外是空的,但根据所提供的智商,似乎传输类型是流启动,所以我想可能是asmack犯规发现它在默认情况下,没有任何一个有此任何解决方案,或者知道如何发现流启动?非常感谢提前3;哦,并且使用的Openfire服务器IM:)

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 <3oh and im using OpenFire server :)

推荐答案

OOOkkk,只是找到了解决办法,我是对这个问题,很抱歉aSmack疲软,只是添加该字段:

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"); 

让你aSmack支持StreamInitiation ....相信这解决了很多的脂肪酶的问题。

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"

和最重要的部分:使用Asmack 8-4.0.0 RC-1是肯定的,最适合用于文件传输的任何问题,生病很乐意帮助,经过1 fckin周尝试我想我学到了很多东西。谢谢

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

这篇关于aSmack文件传输返回NPE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 10:03