Загрузить файл, брось IO Exception, когда Gate GatewayJAVA

Программисты JAVA общаются здесь
Anonymous
Загрузить файл, брось IO Exception, когда Gate Gateway

Сообщение Anonymous »

api файла загрузки доступа, используя исключение Resttemplate Throw IO, когда проход шлюз.

Код: Выделить всё

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: Connection reset by peer] with root cause
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.8.0_333]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.8.0_333]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_333]
at sun.nio.ch.IOUtil.read(IOUtil.java:197) ~[na:1.8.0_333]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:378) ~[na:1.8.0_333]
...
...
...
Caused by: java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_333]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_333]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_333]
at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_333]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:469) ~[na:1.8.0_333]
< /code>
 code < /h2>
            MultiValueMap dataMap = new LinkedMultiValueMap();
dataMap.add("files", new FileSystemResource(filePath));
dataMap.add("presetfolder", JSON.parse(""));

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.add("accept", "*/*");
headers.add("connection", "Keep-Alive");
headers.add("Accept-Charset", "utf-8");
headers.add("X-Token", xToken);
headers.add("Strapp", "");

HttpEntity requestParams = new HttpEntity(dataMap, headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity response = restTemplate.postForEntity(url, requestParams, Object.class);
Object body = response.getBody();
result = JSONObject.parseObject(JSONObject.toJSONString(body), Result.class);
< /code>
 config < /h2>

 Gateway < /li>
< /ul>
spring:
application:
name:
servlet:
multipart:
max-file-size: 1024MB
max-request-size: 1024MB
enabled: true

hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 2000000
ribbon:
ReadTimeout: 2000000
ConnectTimeout: 2000000
eureka:
enabled: true
zuul:
host:
socket-timeout-millis: 2000000
connect-timeout-millis: 2000000
routes:
fileweb:
path: /fileweb/**
serviceId: fileweb
< /code>
 развернуть < /h2>

 Gateway и Target API на том же сервере, запуск на другой сервер < /li>
 host hole < /ul>
 сначала выполняет.curl -X POST http://${server host and port}/fileweb/upload/uploadFile \
-H "Content-Type: multipart/form-data" \
-H "X-Token:" \
-F "files=@test.txt" \
-F 'presetfolder=[{"name":""},{"name":"","parentName":""}]'
затем попробуйте httpurlconnection вместо Resttemplate
Не разрешение


Подробнее здесь: https://stackoverflow.com/questions/797 ... ss-gateway

Вернуться в «JAVA»