0

I'm using apache HttpClient to upload firmware files (.bin). When I upload a such file with size 37MB, I get an error: Connection reset by peer: socket write error. I don't know how to solve it. But when I try other files with smaller size (like .txt or .bin), there isn't any error.

Here's some related code:

HttpPost request = new HttpPost(httpURL);
request.addHeader("Content-Type", "multipart/form-data");
request.addHeader("Accept", "multipart/form-data");

File file = new File(filePath);
FileBody fileBody = new FileBody(file, ContentType.MULTIPART_FORM_DATA);

MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
multipartEntityBuilder.addPart("upgradeFile", fileBody);
multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
HttpEntity httpEntity = multipartEntityBuilder.build();

request.setEntity(httpEntity);
CloseableHttpResponse response = httpClient.execute(request);

PS: I cannot touch the server side.

Silver
  • 77
  • 10
  • Then you can't solve it. The server has closed the connection, apparently based on the upoad size. – user207421 Oct 24 '16 at 10:20
  • @EJP I think so. But what confused me is, the server has an official web page (client side), I can upload a large file from this site but in my code I cannot. – Silver Oct 24 '16 at 12:24

1 Answers1

0

It looks like the problem is on server-side apache/php config. Probably server administrator should change upload_max_filesize and post_max_size parameters in php.ini file. Here is the link on SO to do that:

PHP change the maximum upload file size

Community
  • 1
  • 1
blackhawk4152
  • 390
  • 2
  • 13