Q
Q
QFCFC2018-11-11 14:34:30
Java
QFCFC, 2018-11-11 14:34:30

Why can't upload the file to the server?

I'm trying to upload a file to a server that I'm connecting to via the WebDAV protocol.
It turns out to upload small files. But files in the region of 50KB (+ -5KB) will most likely not be sent (but they can, if it doesn’t have to). Files with a large weight, respectively, are not transferred at all.
Most common mistake:

Exception in thread "main" java.net.SocketException: Software caused connection abort: socket write error
  at java.net.SocketOutputStream.socketWrite0(Native Method)

There is also this one:
Exception in thread "main" java.net.SocketException: Connection reset by peer: socket write error
  at java.net.SocketOutputStream.socketWrite0(Native Method)

But it is more difficult to get it (pops up in the same conditions).
Server request code:
byte[] data = getDataForRequest();
//ByteArrayEntity byteArrayEntity = new ByteArrayEntity(data);
BasicHttpEntity entity = new BasicHttpEntity();

HttpPut httpPut = new HttpPut(file);
//httpPut.setEntity(new BufferedHttpEntity(byteArrayEntity));

ByteArrayInputStream bis = new ByteArrayInputStream(data);
entity.setContent(bis);
entity.setContentLength(data.length);
httpPut.setEntity(new BufferedHttpEntity(entity));

setCommonHeaders(httpPut);

HttpResponse response = getClient().execute(HTTP_HOST, httpPut);

Note: The Apache HttpComponents library is being used
. What could be the problem? I remind you that the code works for small files.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question