Skip to content

Failed to flush rest response,通道写数据之前异常关闭 #1749

@jiangqiushi

Description

@jiangqiushi

还未写数据,链路异常,服务端code

        PipedInputStream in = new PipedInputStream();
        PipedOutputStream out = new PipedOutputStream(in);

        // 启动线程,异步线程outputStream写数据
        TTSTask serviceImpl = new TTSTask(ttsParam, out, paramMap, in);
        ThreadPoolUtil.getPool().submit(serviceImpl);

        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.set("Content-Type", "application/octet-stream");
        return ResponseEntity.ok().headers(responseHeaders).body(in);

服务端配置

rest:
    address: 10.33.106.233:18083?sslEnabled=false
    server:
      verticle-count: 32
      connection:
        idleTimeoutInSeconds: 60
2020-05-14 17:15:17.433 | ERROR | [vert.x-eventloop-thread-10] | [AbstractRestInvocation] | Failed to execute HttpServerFilters, operation:tts_service.ttsservice.processTTS, request uri:/v1/tts/text2audio
java.util.concurrent.CompletionException: io.vertx.core.VertxException: Connection was closed
        at java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:326) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture.completeRelay(CompletableFuture.java:338) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture.uniRelay(CompletableFuture.java:911) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture$UniRelay.tryFire(CompletableFuture.java:899) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977) ~[?:1.8.0_191]
        at org.apache.servicecomb.foundation.vertx.stream.InputStreamToReadStream.handleException(InputStreamToReadStream.java:135) ~[foundation-vertx-1.3.0.jar:1.3.0]
        at org.apache.servicecomb.foundation.vertx.stream.PumpCommon.lambda$pump$0(PumpCommon.java:51) ~[foundation-vertx-1.3.0.jar:1.3.0]
        at io.vertx.core.http.impl.HttpServerResponseImpl.handleClosed(HttpServerResponseImpl.java:561) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.http.impl.HttpServerResponseImpl.handleException(HttpServerResponseImpl.java:535) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.http.impl.HttpServerRequestImpl.handleException(HttpServerRequestImpl.java:569) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.http.impl.Http1xServerConnection.handleClosed(Http1xServerConnection.java:471) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.net.impl.VertxHandler.lambda$channelInactive$5(VertxHandler.java:164) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320) [vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43) [vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:188) [vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:180) [vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.net.impl.VertxHandler.channelInactive(VertxHandler.java:164) [vertx-core-3.6.3.jar:3.6.3]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.handler.timeout.IdleStateHandler.channelInactive(IdleStateHandler.java:277) [netty-handler-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:390) [netty-codec-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:355) [netty-codec-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1429) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:947) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [netty-common-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) [netty-common-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:466) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-common-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.31.Final.jar:4.1.31.Final]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
Caused by: io.vertx.core.VertxException: Connection was closed
2020-05-14 17:15:17.434 | ERROR | [vert.x-eventloop-thread-10] | [AbstractRestInvocation] | Failed to flush rest response, operation:tts_service.ttsservice.processTTS, request uri:/v1/tts/text2audio
java.lang.IllegalStateException: Response is closed
        at io.vertx.core.http.impl.HttpServerResponseImpl.checkValid(HttpServerResponseImpl.java:576) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.http.impl.HttpServerResponseImpl.end(HttpServerResponseImpl.java:324) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.http.impl.HttpServerResponseImpl.end(HttpServerResponseImpl.java:367) ~[vertx-core-3.6.3.jar:3.6.3]
        at org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse.internalFlushBuffer(VertxServerResponseToHttpServletResponse.java:118) ~[foundation-vertx-1.3.0.jar:1.3.0]
        at org.apache.servicecomb.foundation.vertx.http.VertxServerResponseToHttpServletResponse.flushBuffer(VertxServerResponseToHttpServletResponse.java:107) ~[foundation-vertx-1.3.0.jar:1.3.0]
        at org.apache.servicecomb.common.rest.AbstractRestInvocation.onExecuteHttpServerFiltersFinish(AbstractRestInvocation.java:306) ~[common-rest-1.3.0.jar:1.3.0]
        at org.apache.servicecomb.common.rest.AbstractRestInvocation.lambda$executeHttpServerFilters$3(AbstractRestInvocation.java:295) ~[common-rest-1.3.0.jar:1.3.0]
        at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977) ~[?:1.8.0_191]
        at org.apache.servicecomb.common.rest.filter.HttpServerFilterBeforeSendResponseExecutor.lambda$doRun$0(HttpServerFilterBeforeSendResponseExecutor.java:81) ~[common-rest-1.3.0.jar:1.3.0]
        at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:760) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:736) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) ~[?:1.8.0_191]
        at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977) ~[?:1.8.0_191]
        at org.apache.servicecomb.foundation.vertx.stream.InputStreamToReadStream.handleException(InputStreamToReadStream.java:135) ~[foundation-vertx-1.3.0.jar:1.3.0]
        at org.apache.servicecomb.foundation.vertx.stream.PumpCommon.lambda$pump$0(PumpCommon.java:51) ~[foundation-vertx-1.3.0.jar:1.3.0]
        at io.vertx.core.http.impl.HttpServerResponseImpl.handleClosed(HttpServerResponseImpl.java:561) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.http.impl.HttpServerResponseImpl.handleException(HttpServerResponseImpl.java:535) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.http.impl.HttpServerRequestImpl.handleException(HttpServerRequestImpl.java:569) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.http.impl.Http1xServerConnection.handleClosed(Http1xServerConnection.java:471) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.net.impl.VertxHandler.lambda$channelInactive$5(VertxHandler.java:164) ~[vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320) [vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43) [vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:188) [vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:180) [vertx-core-3.6.3.jar:3.6.3]
        at io.vertx.core.net.impl.VertxHandler.channelInactive(VertxHandler.java:164) [vertx-core-3.6.3.jar:3.6.3]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.handler.timeout.IdleStateHandler.channelInactive(IdleStateHandler.java:277) [netty-handler-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:390) [netty-codec-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:355) [netty-codec-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1429) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:947) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [netty-common-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) [netty-common-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:466) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-common-4.1.31.Final.jar:4.1.31.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.31.Final.jar:4.1.31.Final]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
2020-05-14 17:15:17.434 | WARN  | [vert.x-eventloop-thread-10] | [HttpStatusItem] | Response is closed before sending any data. Please check idle connection timeout for provider is properly configured.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions