我正在尝试使用 ejabberd-18.06 和 SMACK-4.2.4 作为Android客户端在应用程序之间传输文件。
mod_http_upload在ejabberd中配置,并使用SMACK中的 HttpFileUploadManager 。
但是,当我尝试上传文件时,它不会上传。我从 HttpFileUploadManager
中收到以下概述的错误java.io.EOFException:\ n找不到:size = 0 content = ...
W/System.err: java.io.IOException: unexpected end of stream on com.android.okhttp.Address@28cebefd
W/System.err: at com.android.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:201)
at com.android.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:737)
W/System.err: at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:609)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:471)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:538)
at org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager.uploadFile(HttpFileUploadManager.java:456)
W/System.err: at org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager.uploadFile(HttpFileUploadManager.java:261)
at org.jivesoftware.smackx.httpfileupload.HttpFileUploadManager.uploadFile(HttpFileUploadManager.java:236)
at time.friends.myapplication.ChatFragment$4.run(ChatFragment.java:244)
at java.lang.Thread.run(Thread.java:764)
W/System.err: Caused by: java.io.EOFException: \n not found: size=0 content=...
at com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:200)
at com.android.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
SMACK代码:
HttpFileUploadManager httpFileUploadManager=
HttpFileUploadManager.getInstanceFor(activity.getXmppConnectionManager()
.getConnection());
File file = new File("/mnt/sdcard/img.jpg");
try {
Log.i("UPLOAD_SERVICE",
httpFileUploadManager.isUploadServiceDiscovered()+"");
Log.i("FILE_UPLOAD",httpFileUploadManager.uploadFile( file);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}