apache / apache/servicecomb-java-chassis
[BUG] - 使用iputstreanpart发送文件偶现服务端超时
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 814
- Avg merge
- 8d 23h
- Merged PRs (30d)
- 1
Description
## Steps to Reproduce
服务端报错;
2025-08-27 08:43:58.866 [transport-vert.x-eventloop-thread-6] ERROR - [PumpFromPart.java:lambda$toWriteStream$1:75] - [] - to write stream failed. java.util.concurrent.CompletionException: io.vertx.core.http.HttpClosedException: Connection was closed
at java.base/java.util.concurrent.CompletableFuture.encodeRelay(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.completeRelay(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$UniRelay$tryFire.run(Unknown Source)
客户端报错:
超时配置
rest:
address: 0.0.0.0:8183?sslEnabled=true
client:
thread-count: 8
maxWaitQueueSize: 100000
connection:
maxPoolSize: 10
timeoutInMillis: 5000
keepAliveTimeoutInSeconds: 15
idleTimeoutInSeconds: 50
keepAlive: true
server:
thread-count: 8
compression: false
maxHeaderSize: 8192
timeout: 3000
maxFormAttributeSize: -1
connection:
idleTimeoutInSeconds: 60
服务端代码;
` @RequestMapping(value = "/v1", method = RequestMethod.POST)
public ResponseEntity syncCache(@RequestBody String param) throws Exception {
return ResponseEntity
.ok()
.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE)
.header("result", JSON.toJSONString(result))
.body(new InputStreamPart(null, sendFile != null ? Files.newInputStream(sendFile) : new ByteArrayInputStream(new byte[0]))
.setSubmittedFileName("data.dat"));
}`
客户端代码
` ResponseEntity response = REST_TEMPLATE.postForEntity("cse://xxxx", body, ReadStreamPart.class);
try {
body.saveToFile(tempDataFile.toFile(), new OpenOptions().setCreateNew(true)).get(30, TimeUnit.SECONDS);
} catch (Exception e) {
Files.deleteIfExists(tempDataFile);
throw e;
}`
发送的文件大小不超过4M,内网万兆带宽网络稳定,排除网络问题,万分之1概率出现文件拉取超时, 辛苦帮忙看一下是使用的问题还是存在竞态问题,文件是在server另外的定时任务定时刷新,创建tmp文件后原子重命名方式,原理上不会影响文件下载。
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.