我試圖使用smack擴展庫4.2.0傳輸文件,但無法成功傳輸文件。當我嘗試傳輸文件,這是我收到無法使用smack傳輸文件'XMPPError:service-unavailable - cancel'
org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPP error reply received from [email protected]/Smack: XMPPError: service-unavailable - cancel
即使對00006在線的錯誤,但我不知道爲什麼我從同行
接收錯誤這是我的代碼傳輸文件
public void sendImageMessage(String sendTo, String imagePath) throws XmppStringprepException {
FileTransferManager manager = FileTransferManager.getInstanceFor(mConnection);
EntityBareJid jid = JidCreate.entityBareFrom(sendTo);
EntityFullJid entityFullJid = JidCreate.entityFullFrom(jid+"/Smack");
Domainpart domainpart = entityFullJid.getDomain();
// Log.d(TAG ," JID Domain "+entityFullJid.do)
OutgoingFileTransfer outgoingFileTransfer = manager.createOutgoingFileTransfer(entityFullJid);
File file = new File(imagePath);
try {
outgoingFileTransfer.sendFile(file, file.getName());
} catch (SmackException e) {
e.printStackTrace();
}
while (!outgoingFileTransfer.isDone()) {
if (outgoingFileTransfer.getStatus().equals(FileTransfer.Status.error)) {
System.out.println("ERROR!!! " + outgoingFileTransfer.getError());
} else if (outgoingFileTransfer.getStatus().equals(FileTransfer.Status.cancelled)
|| outgoingFileTransfer.getStatus().equals(FileTransfer.Status.refused)) {
System.out.println("Cancelled!!! " + outgoingFileTransfer.getError());
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
if (outgoingFileTransfer.getStatus().equals(FileTransfer.Status.refused) || outgoingFileTransfer.getStatus().equals(FileTransfer.Status.error)
|| outgoingFileTransfer.getStatus().equals(FileTransfer.Status.cancelled)) {
System.out.println("refused cancelled error" + outgoingFileTransfer.getError().toString());
} else {
System.out.println("Successfully_SEND");
}
任何幫助和指導是非常讚賞
編輯:我的用戶SP ark客戶端使用我的服務器傳輸文件,它可靠地傳輸文件。所以問題不在於服務器我在客戶端的代碼中。