4

I've been struggeling with the following problem for a long time, but couldn't solve it at all. Im trying a file transfer via xmpp using smack for Android with the following code:

fTManager = FileTransferManager.getInstanceFor(connection);
            fTManager.addFileTransferListener(new FileTransferListener() {
                @Override
                public void fileTransferRequest(FileTransferRequest fileTransferRequest) {
                    String requerstor = fileTransferRequest.getRequestor();
                    try {
                        IncomingFileTransfer transfer = fileTransferRequest.accept();
                        transfer.recieveFile(new File(getExternalFilesDir(null), transfer.getFileName()));

                        bufferedReader = new BufferedReader(new FileReader(new File(getExternalFilesDir(null), transfer.getFileName())));
                        String line;
                        while ((line = bufferedReader.readLine()) != null)
                            Log.i("Line", "LINE " + line);
                        while (!transfer.isDone()) {
                            Thread newThread = new Thread();
                            Log.i("FileTransferManager", "File transfer is " + String.format("%1$,.2f", transfer.getProgress() * 100) + "% complete.");
                            try {
                                newThread.sleep(1000);
                            } catch (InterruptedException e) {e.printStackTrace();}
                        }

                        if (transfer.isDone())
                            Log.i("FileTransferManager", "Transfer status is:" + transfer.getStatus());
                        if (transfer.getError() != null)
                            Log.i("FileTransferManager", "Transfer error occurred:" + transfer.getError().getMessage());
                        if(transfer.getException() != null)
                            transfer.getException().printStackTrace();
                        }
                     catch (SmackException e) {e.printStackTrace();}
                     catch (IOException e) { e.printStackTrace();}

If I get a file transfer request the requestor and file name could be shown. But if transfer.recieveFile(new File(getExternalFilesDir(null), transfer.getFileName()));

should be executed the following error occurs:

03-23 12:47:37.890      888-916/? W/System.err﹕ org.jivesoftware.smack.SmackException: Error in execution
    03-23 12:47:37.890      888-916/? W/System.err﹕ at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:199)
    03-23 12:47:37.900      888-916/? W/System.err﹕ at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.access$100(IncomingFileTransfer.java:57)
    03-23 12:47:37.900      888-916/? W/System.err﹕ at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer$1.run(IncomingFileTransfer.java:129)
    03-23 12:47:37.900      888-916/? W/System.err﹕ at java.lang.Thread.run(Thread.java:841)
    03-23 12:47:37.900      888-916/? W/System.err﹕ Caused by: java.util.concurrent.ExecutionException: org.jivesoftware.smack.SmackException: SOCKS5 negotiation failed
    03-23 12:47:37.920      888-916/? W/System.err﹕ at java.util.concurrent.FutureTask.report(FutureTask.java:93)
    03-23 12:47:37.920      888-916/? W/System.err﹕ at java.util.concurrent.FutureTask.get(FutureTask.java:177)
    03-23 12:47:37.920      888-916/? W/System.err﹕ at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(IncomingFileTransfer.java:193)
    03-23 12:47:37.930      888-916/? W/System.err﹕ ... 3 more
    03-23 12:47:37.930      888-916/? W/System.err﹕ Caused by: org.jivesoftware.smack.SmackException: SOCKS5 negotiation failed
    03-23 12:47:37.930      888-916/? W/System.err﹕ at org.jivesoftware.smackx.bytestreams.socks5.Socks5Client$1.call(Socks5Client.java:105)
    03-23 12:47:37.930      888-916/? W/System.err﹕ at org.jivesoftware.smackx.bytestreams.socks5.Socks5Client$1.call(Socks5Client.java:80)
    03-23 12:47:37.940      888-916/? W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    03-23 12:47:37.940      888-916/? W/System.err﹕ ... 1 more

I am using smack-4.1.0-rc4. Does anybody got a clue for me? I would appreciate some advices.

Piuma
  • 41
  • 3
  • did you get any solution ? – Ajay Aug 01 '16 at 14:00
  • The porblem seemed to be on the server-side. The file transfer did work if the two clients were in the same network, but if one of them is not in it the above error message showed of. As i tested it via Pigeon it worked as well, even if the two clients were not in the same network. That's possible because Pigeon uses a proxy, if the two clients are not in the same network. So, my advice is to intuduce a proxy to your server and register it while connecting the client to your server. I don't know if there are more elegant solutions, if so please tell me, but with a proxy it does work. – Piuma Aug 02 '16 at 14:54
  • Thanks @Piuma for your reply. – Ajay Aug 03 '16 at 08:09

0 Answers0