问题:无法通过XMPP和OpenFire Server接收发送到我的
Android应用程序的文件.我可以成功发送文件.我使用的asmack jar是asmack-jse-buddycloud-2010.12.11.jar
代码:
connConfig = new ConnectionConfiguration("beta.myCompany.co.uk", 5222);
connConfig.setSASLAuthenticationEnabled(true);
try {
connect("username", "password");
} catch (Exception e) {
e.printStackTrace();
}
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
if(sdm == null)
sdm = new ServiceDiscoveryManager(connection);
fileTransferManager = new FileTransferManager(connection);
FileTransferNegotiator.setServiceEnabled(connection, true);
fileTransferManager.addFileTransferListener(new FileTransferListener() {
@Override
public void fileTransferRequest(FileTransferRequest request) {
IncomingFileTransfer transfer = request.accept();
try {
FileOutputStream fos = openFileOutput(request.getFileName(), Context.MODE_PRIVATE);
InputStream stream = transfer.recieveFile();//THIS FAILS!
fos.write(IOUtils.toByteArray(stream));
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
错误(如果文件是通过Spark发送的):
Error in execution: — caused by:
java.util.concurrent.ExecutionException: No response from file
transfer initiator:
错误(如果文件是通过Adium发送的):
java.util.concurrent.ExecutionException: Could not establish socket
with any provided host: item-not-found(404) Could not establish socket
with any provided host
错误(如果文件是通过我的应用程序的另一个实例发送的):
Error in execution: — caused by:
java.util.concurrent.ExecutionException: — caused by: No response
from remote client:
我的日志:(当试图从Spark接收文件时)
看来我正在发送此错误! (没有收到).为什么会这样?
> 05-01 12:49:36.013: I/System.out(1000): 12:49:35 PM SENT (1093411736):
>
> from="theUsername@beta.myCompany.co.uk/BAM-1918973529" type="error">
> code="501" type="CANCEL">
> xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
额外日志:
05-01 14:46:06.133: I/System.out(1370): 02:46:06 PM RCV (1093401112): Sending filehttp://jabber.org/protocol/bytestreamshttp://jabber.org/protocol/ibb
05-01 14:46:08.283: I/System.out(1370): 02:46:08 PM SENT (1093401112): http://jabber.org/protocol/bytestreams
05-01 14:46:08.312: I/System.out(1370): 02:46:08 PM RCV (1093401112):
05-01 14:46:14.352: W/System.err(1370): Error in execution:
05-01 14:46:14.352: W/System.err(1370): -- caused by: java.util.concurrent.ExecutionException: No response from file transfer initiator:[
[ERROR LOG IS HERE]
05-01 14:46:14.732: I/System.out(1370): 02:46:14 PM SENT (1093401112):
05-01 14:46:14.773: I/System.out(1370): 02:46:14 PM RCV (1093401112):
05-01 14:46:29.783: I/System.out(1370): 02:46:29 PM RCV (1093401112):
05-01 14:46:29.843: I/System.out(1370): 02:46:29 PM SENT (1093401112):