deepverma / asmack

Automatically exported from code.google.com/p/asmack
Other
0 stars 0 forks source link

creating a FileTransferManager doesn't work. #23

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Used code:

m_FTManager = new FileTransferManager(m_Connection);

produces:
E/AndroidRuntime( 8142): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 8142):        at 
org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.setServiceEnabled(Fi
leTransferNegotiator.java:126)
E/AndroidRuntime( 8142):        at 
org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.getInstanceFor(FileT
ransferNegotiator.java:107)
E/AndroidRuntime( 8142):        at 
org.jivesoftware.smackx.filetransfer.FileTransferManager.<init>(FileTransferMana
ger.java:63)

somehow there is no ServiceDiscoveryManager for my connection, which is why 
null is returned by ServiceDiscoveryManager.getInstanceFor().

Original issue reported on code.google.com by un.v...@gmail.com on 16 Jun 2010 at 11:47

GoogleCodeExporter commented 8 years ago
With asmack-issue-13.jar, I can make FileTransferManager object, but it also 
failed to transfer file with service-unavailable error like this.
I'm testing with android client with asmack, OpenFire server for Windows, and 
Spark for Windows.

07-19 02:54:47.307: DEBUG/SMACK(228): 02:54:47 AM SENT (1135385920): <iq 
id="Gnn6w-26" to="test2@testmachine" from="test@testmachine/Smack" 
type="set"><si xmlns="http://jabber.org/protocol/si" 
id="jsi_9109545620352116371" 
profile="http://jabber.org/protocol/si/profile/file-transfer"><file 
xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="forest.jpg" 
size="128068" ><desc>You won't believe this!</desc></file><feature 
xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" 
type="form"><field var="stream-method" 
type="list-multi"><option><value>http://jabber.org/protocol/bytestreams</value><
/option><option><value>http://jabber.org/protocol/ibb</value></option></field></
x></feature></si></iq>
07-19 02:54:47.410: DEBUG/SMACK(228): 02:54:47 AM RCV  (1135385920): <iq 
type="error" id="Gnn6w-26" from="test2@testmachine" 
to="test@testmachine/Smack"><si xmlns="http://jabber.org/protocol/si" 
id="jsi_9109545620352116371" 
profile="http://jabber.org/protocol/si/profile/file-transfer"><file 
xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="forest.jpg" 
size="128068"><desc>You won't believe this!</desc></file><feature 
xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" 
type="form"><field var="stream-method" 
type="list-multi"><option><value>http://jabber.org/protocol/bytestreams</value><
/option><option><value>http://jabber.org/protocol/ibb</value></option></field></
x></feature></si><error code="503" type="cancel"><service-unavailable 
xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

Any ideas?

Original comment by sgki...@gmail.com on 19 Jul 2010 at 6:32

GoogleCodeExporter commented 8 years ago
I have some more progress on this issue.
As the file transfer API document guided, I put a fully-qualified jabber ID 
consists of a node, a domain, and a resource, then I can see the file transfer 
view in Spark.
But I can see the following error, when I clicked 'accept' in Spark chat window.

Thread [<23> File Transfer jsi_2403365644062062677] (Suspended (exception 
ClassCastException))    
    FileTransferNegotiator.negotiateOutgoingTransfer(String, String, String, long, String, int) line: 401   
    OutgoingFileTransfer.negotiateStream(String, long, String) line: 359    
    OutgoingFileTransfer.access$100(OutgoingFileTransfer, String, long, String) line: 35    
    OutgoingFileTransfer$2.run() line: 214  
    Thread.run() line: 1096 

There is no problem with sample application using Smack in windows.

Original comment by sgki...@gmail.com on 19 Jul 2010 at 9:05

GoogleCodeExporter commented 8 years ago
When I added configure function as Mike showed in the link ( 
http://community.igniterealtime.org/message/201866#201866 ), ClassCastException 
error had gone, but the file transfer failed too.

Spark log shows there is error and I can't found any error log in Android side.

2010. 7. 20 오후 2:42:36 org.jivesoftware.spark.util.log.Log error
심각: There was an error during file transfer.
Error in execution: 
  -- caused by: java.util.concurrent.ExecutionException: File transfer negotiation failed.: 
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:199)
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.access$100(IncomingFileTransfer.java:47)
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$1.run(IncomingFileTransfer.java:124)
    at java.lang.Thread.run(Unknown Source)
Nested Exception: 
java.util.concurrent.ExecutionException: File transfer negotiation failed.: 
    at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:193)
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.access$100(IncomingFileTransfer.java:47)
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$1.run(IncomingFileTransfer.java:124)
    at java.lang.Thread.run(Unknown Source)
Caused by: File transfer negotiation failed.: 
    at org.jivesoftware.smackx.filetransfer.FaultTolerantNegotiator.createIncomingStream(FaultTolerantNegotiator.java:128)
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$2.call(IncomingFileTransfer.java:186)
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$2.call(IncomingFileTransfer.java:185)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:190)
    ... 3 more

Original comment by sgki...@gmail.com on 20 Jul 2010 at 5:49

GoogleCodeExporter commented 8 years ago
Eventually I succeeded to transfer file by disabling proxy support on OpenFire 
server. :)

Original comment by sgki...@gmail.com on 21 Jul 2010 at 6:38

GoogleCodeExporter commented 8 years ago
I found a trick and finally fixed the problem by inserting the following code 
before instantiaging a FileTransferManager.

// you have to make a dummy service discovery manager.
new ServiceDiscoveryManager(your XMPP connection);
// now this line does not cause any problems.
mFileTransferManager = new FileTransferManager(your XMPP connection);

Even though the code removes the NullPointerException, there still exists a 
problem.
You will see "ClassCastException : PacketParserUtils$2" :(
I finally found the solution.
When you connect to XMPP server, SMACK API automatically loads the 
"META-INF/smack.providers" file and reads several packet processing providers. 
Android does not allow this, I guess this is a kind of security issue. 
Therefore, the code of Android SMACK API should be fixed.
Though this is a permanent remedy, you can successfully transfer a file with 
the following code snippet.

First, you have to copy a smack.properties to you android emulator.
You can get smack.properties at the original SMACK API site.

http://www.igniterealtime.org/downloads/source.jsp

For example, I pushed  smack.properties into "/data/" folder.

After that, I modified initialize() method of ProviderManager.java (it's in 
org/jivesoftware/smack/provider) as follows.

Find the following line.
                Enumeration providerEnum = classLoader.getResources(
                        "/META-INF/smack.providers");
Replace it with
                Enumeration providerEnum = classLoader.getResources(
                        "/data/smack.providers");

I hope this helps.

Original comment by agnos....@gmail.com on 21 Jul 2010 at 11:25

GoogleCodeExporter commented 8 years ago
Thank you for summarizing the procedure to fix the problem.
My way is almost same with yours. :)

Original comment by sgki...@gmail.com on 22 Jul 2010 at 2:58

GoogleCodeExporter commented 8 years ago
Thank you for helping us to proceed.

Hi agnos.kim,

I am using asmack-2010.05.07-source in eclipse for android-2.2.

After adding your solution

<solution
Enumeration providerEnum = classLoader.getResources(
                        "/META-INF/smack.providers");
Replace it with -
Enumeration providerEnum = classLoader.getResources(
                        "/data/smack.providers");
/>

I am still getting the error

08-01 01:55:51.050: ERROR/AndroidRuntime(1649): java.lang.ClassCastException: 
org.jivesoftware.smack.util.PacketParserUtils$2
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.negotiateOutgoingTra
nsfer(FileTransferNegotiator.java:401)
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.negotiateStream(Outgoi
ngFileTransfer.java:359)
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.access$0(OutgoingFileT
ransfer.java:352)
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer$2.run(OutgoingFileTran
sfer.java:214)
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
java.lang.Thread.run(Thread.java:1096)

Please tell me what i am missing ...

Original comment by chandra....@gmail.com on 1 Aug 2010 at 4:49

GoogleCodeExporter commented 8 years ago

Sorry i missed "Mike's fix showed in the link ( 
http://community.igniterealtime.org/message/201866#201866 ) "

Now it works.

Thank you very much for all your solutions.

All the best !!

Original comment by chandra....@gmail.com on 1 Aug 2010 at 7:22

GoogleCodeExporter commented 8 years ago
I don't get any of the above exceptions when I use asmack 15, but the file 
transfer just doesn't happen. I'm trying to take a picture on the phone, save 
it on the sdcard and then send it via xmpp. Everything in the logs (logcat) 
looks fine and I can see chat messages but no files. Any ideas?

Thanks,
Neha.

Original comment by neha...@gmail.com on 20 Oct 2010 at 5:19

GoogleCodeExporter commented 8 years ago
Today ,I succeeded to transfer file by Using“asmack-issue15.jar” & in 
android2.3 .
Thanks,
Chen Wen 

Original comment by TT0...@gmail.com on 12 Jan 2011 at 3:35

GoogleCodeExporter commented 8 years ago
I am trying to send a file to a simple asmack client, but the packets seem to 
get lost somewhere.  I've used a number of asmack builds (asmack-issue15, a 
rtreffer source build, etc.), but they all lead me to the same result.  The 
stream negotiation works fine, but the actual transfer never seems to happen.  
I get the following debug output:

XMPPClient: status: Initial
XMPPClient: Progress: 0.0/10
XMPPClient: status: Negotiating Stream
XMPPClient: Progress: 0.0/10
XMPPClient: status: In Progress
XMPPClient: Progress: 0.0/10
XMPPClient: status: In Progress
XMPPClient: Progress: 0.0/10
XMPPClient: status: In Progress
XMPPClient: Progress: 0.0/10
... and continues indefinitely

The file sending dialog on the Tkabber client closes as though it successfully 
sent the file, but the android client keeps waiting.  

I noticed that the inputStream in IncomingFileTransfer.receiveFile has a null 
buffer (and the writeToStream call blocks), which means that it never receives 
any packets.  I don't get any exceptions or any other signs that something is 
wrong.  Any help would be greatly appreciated!

Thank you,
Andrey

Original comment by tur...@gmail.com on 29 Jan 2011 at 1:55

GoogleCodeExporter commented 8 years ago
Hello.

I am still getting the error

08-01 01:55:51.050: ERROR/AndroidRuntime(1649): java.lang.ClassCastException: 
org.jivesoftware.smack.util.PacketParserUtils$2
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
org.jivesoftware.smackx.filetransfer.FileTransferNegotiator.negotiateOutgoingTra
nsfer(FileTransferNegotiator.java:401)
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.negotiateStream(Outgoi
ngFileTransfer.java:359)
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.access$0(OutgoingFileT
ransfer.java:352)
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer$2.run(OutgoingFileTran
sfer.java:214)
08-01 01:55:51.050: ERROR/AndroidRuntime(1649):     at 
java.lang.Thread.run(Thread.java:1096)

Where is the problem?

It's probably a problem of type of packets to send.

Original comment by moussaou...@gmail.com on 12 Mar 2011 at 9:04

GoogleCodeExporter commented 8 years ago
I have the same question as 
"Comment 11 by tur...@gmail.com, Jan 28, 2011"
asmack client(phone) send file to spark client(pc)

Original comment by liu0198...@gmail.com on 14 May 2011 at 10:51

GoogleCodeExporter commented 8 years ago
I've got the same problem as #11 and #13. 
I'm trying to send a file from asmack to a Spark client, but nothing ever 
happens. 

Original comment by mrm.s...@gmail.com on 16 May 2011 at 11:29

GoogleCodeExporter commented 8 years ago
I also get the same problem as #11, #13 and #14 
Try to send from asmack 15 to Smack 3.2 

Original comment by gokhan.a...@gmail.com on 2 Jun 2011 at 6:13

GoogleCodeExporter commented 8 years ago
All of these cast cast exceptions are being caused by the provider list not 
being loaded. You need to edit the ProviderManager to load the provider list 
from a specific location of your choice(you have to move your smack.providers 
file there).

Original comment by Jug6ern...@gmail.com on 3 Jun 2011 at 6:21

GoogleCodeExporter commented 8 years ago
Get the same problem as #11 #14

Original comment by redmapl...@gmail.com on 8 Jun 2011 at 10:15

GoogleCodeExporter commented 8 years ago
Hi, 
I am trying to do file transfer with asmack-issue15.jar from emulator to spark.
But after I click accept in spark, transfer is terminated and spark is showing 
'The file transfer was cancelled'. When I checked the logs, in between a close 
iq is sent to spark.

<message id="09VYB-16_0" to="babu@10.18.63.240/spark"><data 
xmlns="http://jabber.org/protocol/ibb" sid="jsi_7520933358958346087" 
seq="0">aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9wL2FuZHJvaWQvaXNzdWVzL2RldGFpbD9pZD0xMzcx
NQ==</data></message>
<message id="09VYB-16_1" to="babu@10.18.63.240/spark"><data 
xmlns="http://jabber.org/protocol/ibb" sid="jsi_7520933358958346087" 
seq="1"></data></message>
<iq id="09VYB-17" to="babu@10.18.63.240/spark" type="set"><close 
xmlns="http://jabber.org/protocol/ibb" sid="jsi_7520933358958346087"/></iq>
<iq id="09VYB-17" to="test1@10.18.63.240/Smack" from="babu@10.18.63.240/spark" 
type="result"/>

Please help me to resolve this.

Original comment by archana...@gmail.com on 16 Jun 2011 at 5:27

GoogleCodeExporter commented 8 years ago
i am unable to find smack.properties file from the given page.i downloaded the 
smack source code and didnt find smack.properties file

Original comment by xardo...@gmail.com on 9 Aug 2011 at 10:07

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
private void configure(ProviderManager pm) {
        //  Private Data Storage
        pm.addIQProvider("query","jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider());

        //  Time
        try {
            pm.addIQProvider("query","jabber:iq:time", Class.forName("org.jivesoftware.smackx.packet.Time"));
        } catch (ClassNotFoundException e) {
            Log.w(Tools.LOG_TAG, "Can't load class for org.jivesoftware.smackx.packet.Time");
        }

        //  XHTML
        pm.addExtensionProvider("html","http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider());

        //  Roster Exchange
        pm.addExtensionProvider("x","jabber:x:roster", new RosterExchangeProvider());
        //  Message Events
        pm.addExtensionProvider("x","jabber:x:event", new MessageEventProvider());
        //  Chat State
        pm.addExtensionProvider("active","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
        pm.addExtensionProvider("composing","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
        pm.addExtensionProvider("paused","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
        pm.addExtensionProvider("inactive","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
        pm.addExtensionProvider("gone","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());

        //   FileTransfer
        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());

        //  Group Chat Invitations
        pm.addExtensionProvider("x","jabber:x:conference", new GroupChatInvitation.Provider());
        //  Service Discovery # Items    
        pm.addIQProvider("query","http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
        //  Service Discovery # Info
        pm.addIQProvider("query","http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
        //  Data Forms
        pm.addExtensionProvider("x","jabber:x:data", new DataFormProvider());
        //  MUC User
        pm.addExtensionProvider("x","http://jabber.org/protocol/muc#user", new MUCUserProvider());
        //  MUC Admin    
        pm.addIQProvider("query","http://jabber.org/protocol/muc#admin", new MUCAdminProvider());
        //  MUC Owner    
        pm.addIQProvider("query","http://jabber.org/protocol/muc#owner", new MUCOwnerProvider());
        //  Delayed Delivery
        pm.addExtensionProvider("x","jabber:x:delay", new DelayInformationProvider());
        //  Version
        try {
            pm.addIQProvider("query","jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version"));
        } catch (ClassNotFoundException e) {
            Log.w(Tools.LOG_TAG, "Can't load class for org.jivesoftware.smackx.packet.Version");
        }
        //  VCard
        pm.addIQProvider("vCard","vcard-temp", new VCardProvider());
        //  Offline Message Requests
        pm.addIQProvider("offline","http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider());
        //  Offline Message Indicator
        pm.addExtensionProvider("offline","http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider());
        //  Last Activity
        pm.addIQProvider("query","jabber:iq:last", new LastActivity.Provider());
        //  User Search
        pm.addIQProvider("query","jabber:iq:search", new UserSearch.Provider());
        //  SharedGroupsInfo
        pm.addIQProvider("sharedgroup","http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider());
        //  JEP-33: Extended Stanza Addressing
        pm.addExtensionProvider("addresses","http://jabber.org/protocol/address", new MultipleAddressesProvider());
    }

from 
http://code.google.com/r/fschmaus-gtalksms/source/browse/src/com/googlecode/gtal
ksms/XmppManager.java

call configure(ProviderManager.getInstance()) is valid instead of changes in 
initialize() method of ProviderManager.java?

Now, I have error on start of file transfering as follows error 
code=503(service-unavailable) when reciever is offline and error 
code=501(feature-not-implemented) when it's online and have 
FileTransferListener()

Original comment by nizh...@gmail.com on 9 Aug 2011 at 8:46

GoogleCodeExporter commented 8 years ago
There isn't a smack.properties file in the source i had downloaded , i searched 
it on my computer but still not found . Can anyone provide? Greatly appreciated!

Original comment by javahf...@gmail.com on 2 Nov 2011 at 4:11

GoogleCodeExporter commented 8 years ago
I have the Same problem as in Comment no. 11 . Please help me . 
Thanks in advance.

Original comment by nitin....@gmail.com on 24 Aug 2012 at 7:16

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
comment 21 :  it is related to the asmack.jar , you can check issue 61 .
or you can use the jar file below:
http://www.eoeandroid.com/forum.php?mod=viewthread&tid=81207&page=1#pid863576

Original comment by zhengkan...@gmail.com on 3 Dec 2012 at 4:37

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
You will find a version which contains a fix for this issue at the new home of 
aSmack: https://github.com/flowdalic/asmack

Please make sure to read the provided README or else it may not work!

Original comment by fschm...@gmail.com on 20 Feb 2013 at 4:41

GoogleCodeExporter commented 8 years ago
I have the same problem as #21 comment. if anyone find the solution please 
explain here

Original comment by rohitsin...@gmail.com on 12 Jun 2014 at 9:16

GoogleCodeExporter commented 8 years ago
I have problem with Offline message retrieval. I am using asmack 4.0.6 at my 
android client side and MongooseIM as server. I am Using ChatManager class to 
organize messages. For Offline messages, if i try to use 
supportFlexibleOfflineRetrieval, its returning false. So how i should implement 
Offline messages at my android client???

Original comment by praveenj...@gmail.com on 3 Feb 2015 at 5:38