使用ASMACK android发送文件(Image)中的item-not-found(404)

时间:2015-01-05 11:16:24

标签: android asmack

我正在尝试在聊天应用程序中发送图像文件。我正在使用asmack-android-8-4.0.6.jar。登录和普通消息工作很好,但我无法发送图像。没有致命的异常,但我总是得到item-not-found(404)消息我正在使用以下代码

 public void sendFile(String picturePath, String to)
{
                CustomLogger.showLog("Bitmap", "path is " + picturePath);
                CustomLogger.showLog("Bitmap", "path is " + to);
                if (xmppConnection == null)
                {
                    CustomLogger.showLog("Service", "connection is null while sending image");
                }
                else
                {
                    CustomLogger.showLog("Service", "connection is not null while sending image");
                    FileTransferNegotiator.setServiceEnabled(xmppConnection, true);
                    manager = new FileTransferManager(xmppConnection);
                    manager.addFileTransferListener(this);
                    OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(to + "/sc");
                    File file = new File(picturePath);

                    try
                    {
                       transfer.sendFile(file, "test_file");
                    } catch (Exception e)
                    {
                        CustomLogger.showLog("Bitmap", "Exception in sending file");
                        e.printStackTrace();
                    }
                    while (!transfer.isDone())
                    {
                        if (transfer.getStatus().equals(FileTransfer.Status.error))
                        {
                            CustomLogger.showLog("Bitmap", "ERROR!!! " + transfer.getError());
                        }
                        else if (transfer.getStatus().equals(FileTransfer.Status.cancelled)
                                || transfer.getStatus().equals(FileTransfer.Status.refused))
                        {
                            CustomLogger.showLog("Bitmap", "Cancelled!!! " + transfer.getError());
                        }
                        try
                        {
                            Thread.sleep(1000L);
                        } catch (InterruptedException e)
                        {
                            e.printStackTrace();
                        }
                    }

                    if (transfer.getStatus().equals(FileTransfer.Status.refused) || transfer.getStatus().equals(FileTransfer.Status.error)
                            || transfer.getStatus().equals(FileTransfer.Status.cancelled))
                    {
                        CustomLogger.showLog("Bitmap", "refused cancelled error " +""+transfer.getError()+"  " + transfer.getException());
                        transfer.getException().printStackTrace();
                    }
                    else
                    {
                        CustomLogger.showLog("Bitmap", "Success in sending");
                    }
                }
            }

堆栈跟踪

item-not-found
W/System.err﹕ at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:196)
W/System.err﹕ at org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager.establishSession(Socks5BytestreamManager.java:493)
W/System.err﹕ at org.jivesoftware.smackx.filetransfer.Socks5TransferNegotiator.createOutgoingStream(Socks5TransferNegotiator.java:63)
W/System.err﹕ at org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.negotiateStream(OutgoingFileTransfer.java:386)
W/System.err﹕ at org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.access$100(OutgoingFileTransfer.java:35)
W/System.err﹕ at org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer$2.run(OutgoingFileTransfer.java:220)
W/System.err﹕ at java.lang.Thread.run(Thread.java:841)

非常感谢任何帮助

0 个答案:

没有答案