powered by Jive Software

File sending using smack 4.2.4


#1

I’m trying to send image and file using smack 4.2.4 and my server is jabb3r.org but without any process, it sends me this error :

XMPP error reply received from fattaneh123@jabb3r.org/Xabber_egtxJrjU: XMPPError: service-unavailable - wait

and my function is :

public void seend(String id, String paht) throws XmppStringprepException{
        ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
        if (sdm == null) {
            sdm = ServiceDiscoveryManager.getInstanceFor(connection);
            sdm.addFeature("http://jabber.org/protocol/disco#info");
            sdm.addFeature("jabber:iq:privacy");
        }
        FileTransferManager manager = FileTransferManager.getInstanceFor(connection);
        final OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(JidCreate.entityFullFrom("fattaneh123@jabb3r.org/Xabber_egtxJrjU"));

        FileTransferNegotiator.IBB_ONLY = true;

        boolean a = FileTransferNegotiator.isServiceEnabled(connection);

        Log.e("ali", a + "");


        final File file = new File(paht);
//        FileTransferNegotiator.getInstanceFor(connection).negotiateOutgoingTransfer(JidCreate.entityFullFrom("fattaneh123@jabb3r.org/Xabber_egtxJrjU"), transfer.getStreamID(), file.getName(), file.length(), "ali", 10000);


        new AsyncTask<Void, Void, Void>() {


            protected void onPreExecute() {

            }

            @Override
            protected Void doInBackground(Void... params) {
                try {
                    transfer.sendFile(file,file.getName());
                } catch (SmackException e) {
                    e.printStackTrace();
                }
                while (!transfer.isDone()) {
                    if (transfer.getStatus().equals("Error")) {
                        Log.d("file transfer",
                                "ERROR!!! " + transfer.getError());

                    } else if (transfer.getStatus().equals("Cancelled")
                            || transfer.getStatus().equals("Refused")) {
                        Log.d("file transfer",
                                "Cancelled!!! " + transfer.getError());
                    }
                    try {
                        Thread.sleep(1000L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                return null;
            }

            protected void onPostExecute(Void result) {

                if (transfer.getStatus().equals("Refused")
                        || transfer.getStatus().equals("Error")
                        || transfer.getStatus().equals("Cancelled")) {
                    Log.i("file transfer", "refused cancelled error "
                            + transfer.getError());

                } else {

                    Log.i("file transfer", "Success: " + transfer.getException().getMessage());
                }
            }

            ;
        }.execute();

    }