在android中使用smack进行文件传输期间:java.util.concurrent.ExecutionException:客户端没有响应

时间:2013-06-21 05:30:38

标签: android xmpp file-transfer smack

public void ReceiveFile() {

        ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);

        if (sdm == null)
        {
            sdm = new ServiceDiscoveryManager(connection);
            Log.e("service discovery", "SDM");
        sdm.addFeature("http://jabber.org/protocol/disco#info");

        sdm.addFeature("jabber:iq:privacy");
        }

        FileTransferManager manager = new FileTransferManager(connection);
        Log.e("after manager", "manager");
        manager.addFileTransferListener(new FileTransferListener() {
           public void fileTransferRequest(final FileTransferRequest request) {
              new Thread(){
                 @Override
                 public void run() {
                     Log.e("Thread running", "starting");
                    IncomingFileTransfer transfer = request.accept();
                    File mf = Environment.getExternalStorageDirectory();
                    Log.e("path", mf.getAbsoluteFile()+"/DCIM/" + transfer.getFileName());
                    File file = new File(mf.getAbsoluteFile()+"/DCIM/" + transfer.getFileName());

                    try{
                        transfer.recieveFile(file);
                        while(!transfer.isDone()) {
                           try{
                              Thread.sleep(1000L);
                           }catch (Exception e) {
                              Log.e("", e.getMessage());
                           }
                           if(transfer.getStatus().equals(org.jivesoftware.smackx.filetransfer.FileTransfer.Status.error)) {
                              Log.e("ERROR!!! ", transfer.getError() + "");
                           }
                           if(transfer.getException() != null) {
                              transfer.getException().printStackTrace();
                              Log.e("not null", "print stack success");
                           }
                        }
                     }catch (Exception e) {
                        Log.e("", e.getMessage());
                    }
                 };
               }.start();
            }
         });    
    }

    public void sndFile(final String path, final String receiver) {
        ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);

        if (sdm == null)
        {
            sdm = new ServiceDiscoveryManager(connection);
            Log.e("service discovery", "SDM");
        sdm.addFeature("http://jabber.org/protocol/disco#info");

        sdm.addFeature("jabber:iq:privacy");
        }

        FileTransferManager manager = new FileTransferManager(connection);
        OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(receiver+"/Smack");
        File file = new File(path);
        try {
           transfer.sendFile(file, "test_file");
        } catch (XMPPException e) {
           e.printStackTrace();
        }
        while(!transfer.isDone()) {
           if(transfer.getStatus().equals(org.jivesoftware.smackx.filetransfer.FileTransfer.Status.error)) {
              System.out.println("ERROR!!! " + transfer.getError());
              Log.e("while status error", "error");

           } else if (transfer.getStatus().equals(org.jivesoftware.smackx.filetransfer.FileTransfer.Status.refused)
                            || transfer.getStatus().equals(org.jivesoftware.smackx.filetransfer.FileTransfer.Status.cancelled)) {
              System.out.println("Cancelled!!! " + transfer.getError());
              Log.e("while Cancelled", "cancel refuse");
           }
           try {
              Thread.sleep(1000L);
           } catch (InterruptedException e) {
              e.printStackTrace();
           }
        }
        if(transfer.getStatus().equals(org.jivesoftware.smackx.filetransfer.FileTransfer.Status.refused) || transfer.getStatus().equals(org.jivesoftware.smackx.filetransfer.FileTransfer.Status.error)
         || transfer.getStatus().equals(org.jivesoftware.smackx.filetransfer.FileTransfer.Status.cancelled)){
           System.out.println("refused cancelled error " + transfer.getError());
           Log.e("if cancelled", "refused cancel");

        } else {
           System.out.println("Success");
           Log.e("if no error", "Success");
           j=0;
           arrList_messages.add("File "+transfer.getFileName()+"Sent");
           arrList_messages.add(" ");
           setListAdapter();
         setListAdapterGreen();
        }
    }

LOGCAT RECEVING:

06-19 11:22:41.911: E/ERROR!!!(15386): null
06-19 11:22:41.912: W/System.err(15386): Error in execution: 
06-19 11:22:41.912: W/System.err(15386):   -- caused by: java.util.concurrent.ExecutionException: 
06-19 11:22:41.912: W/System.err(15386):   -- caused by: No response from remote client: 
06-19 11:22:41.912: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:199)
06-19 11:22:41.912: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.access$100(IncomingFileTransfer.java:47)
06-19 11:22:41.912: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$1.run(IncomingFileTransfer.java:124)
06-19 11:22:41.912: W/System.err(15386):    at java.lang.Thread.run(Thread.java:856)
06-19 11:22:41.912: W/System.err(15386): Nested Exception: 
06-19 11:22:41.912: W/System.err(15386): java.util.concurrent.ExecutionException: 
06-19 11:22:41.912: W/System.err(15386):   -- caused by: No response from remote client: 
06-19 11:22:41.913: W/System.err(15386):    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:233)
06-19 11:22:41.913: W/System.err(15386):    at java.util.concurrent.FutureTask.get(FutureTask.java:90)
06-19 11:22:41.913: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:193)
06-19 11:22:41.913: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.access$100(IncomingFileTransfer.java:47)
06-19 11:22:41.913: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$1.run(IncomingFileTransfer.java:124)
06-19 11:22:41.913: W/System.err(15386):    at java.lang.Thread.run(Thread.java:856)
06-19 11:22:41.913: W/System.err(15386):   -- caused by: No response from remote client: 
06-19 11:22:41.914: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.FaultTolerantNegotiator.createIncomingStream(FaultTolerantNegotiator.java:113)
06-19 11:22:41.914: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$2.call(IncomingFileTransfer.java:186)
06-19 11:22:41.914: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$2.call(IncomingFileTransfer.java:183)
06-19 11:22:41.914: W/System.err(15386):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-19 11:22:41.914: W/System.err(15386):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-19 11:22:41.914: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:190)
06-19 11:22:41.914: W/System.err(15386):    ... 3 more
06-19 11:22:41.914: E/not null(15386): print stack success
06-19 11:22:41.914: E/ERROR!!!(15386): null
06-19 11:22:41.914: W/System.err(15386): Error in execution: 
06-19 11:22:41.914: W/System.err(15386):   -- caused by: java.util.concurrent.ExecutionException: 
06-19 11:22:41.914: W/System.err(15386):   -- caused by: No response from remote client: 
06-19 11:22:41.915: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:199)
06-19 11:22:41.915: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.access$100(IncomingFileTransfer.java:47)
06-19 11:22:41.915: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$1.run(IncomingFileTransfer.java:124)
06-19 11:22:41.915: W/System.err(15386):    at java.lang.Thread.run(Thread.java:856)
06-19 11:22:41.915: W/System.err(15386): Nested Exception: 
06-19 11:22:41.915: W/System.err(15386): java.util.concurrent.ExecutionException: 
06-19 11:22:41.915: W/System.err(15386):   -- caused by: No response from remote client: 
06-19 11:22:41.915: W/System.err(15386):    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:233)
06-19 11:22:41.915: W/System.err(15386):    at java.util.concurrent.FutureTask.get(FutureTask.java:90)
06-19 11:22:41.915: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:193)
06-19 11:22:41.915: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.access$100(IncomingFileTransfer.java:47)
06-19 11:22:41.915: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$1.run(IncomingFileTransfer.java:124)
06-19 11:22:41.915: W/System.err(15386):    at java.lang.Thread.run(Thread.java:856)
06-19 11:22:41.916: W/System.err(15386):   -- caused by: No response from remote client: 
06-19 11:22:41.916: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.FaultTolerantNegotiator.createIncomingStream(FaultTolerantNegotiator.java:113)
06-19 11:22:41.916: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$2.call(IncomingFileTransfer.java:186)
06-19 11:22:41.916: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$2.call(IncomingFileTransfer.java:183)
06-19 11:22:41.916: W/System.err(15386):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-19 11:22:41.916: W/System.err(15386):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-19 11:22:41.916: W/System.err(15386):    at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:190)
06-19 11:22:41.916: W/System.err(15386):    ... 3 more
06-19 11:22:41.916: E/not null(15386): print stack success

LOGCAT发送:

aller requests to read 6415 bytes timeout=0...
06-19 11:25:30.621: D/NativeCrypto(15386): Doing SSL_Read() ssl=0x691328, appData=0x773788
06-19 11:25:30.621: D/NativeCrypto(15386): Returned from SSL_Read() with result -1, error code 2 ssl=0x691328, appData=0x773788
06-19 11:25:30.621: D/NativeCrypto(15386): sslSelect type=READ fd=61 appData=0x773788 timeout=0
06-19 11:25:30.860: D/NativeCrypto(15386): sslSelect READ fd=61 appData=0x773788 timeout=0 => 1
06-19 11:25:30.860: D/NativeCrypto(15386): Doing SSL_Read() ssl=0x691328, appData=0x773788
06-19 11:25:30.860: D/NativeCrypto(15386): Returned from SSL_Read() with result 222, error code 0 ssl=0x691328, appData=0x773788
06-19 11:25:30.863: D/NativeCrypto(15386): Entering sslRead, caller requests to read 6193 bytes timeout=0...
06-19 11:25:30.863: D/NativeCrypto(15386): Doing SSL_Read() ssl=0x691328, appData=0x773788
06-19 11:25:30.863: D/NativeCrypto(15386): Returned from SSL_Read() with result -1, error code 2 ssl=0x691328, appData=0x773788
06-19 11:25:30.863: D/NativeCrypto(15386): sslSelect type=READ fd=61 appData=0x773788 timeout=0
06-19 11:25:31.088: I/System.out(15386): refused cancelled error null
06-19 11:25:31.088: E/if cancelled(15386): refused cancel
06-19 11:25:31.088: E/after manager(15386): manager
06-19 11:25:39.797: I/System.out(15386): close [socket][/0.0.0.0:-1]

0 个答案:

没有答案