SMACK: HttpFileUploadManager getting java.io.EOFException: \n not found: size=0 content=

I am trying to transfer files between applications using ejabberd-18.06 and SMACK-4.2.4 as the android client.

mod_http_upload is configured in ejabberd and using HttpFileUploadManager from SMACK.

But, when i try to upload file, it does not upload. I get the error outlined below from HttpFileUploadManager

java.io.EOFException: \n not found: 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 Code:

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();
  }

Looks like the HTTP server is not terminating its response with a newline character. On the other hand, the size=0 possibly means that there was an empty response.

how can i check ?

Hi, did you fix this problem? I have faced same issue.