当前位置: 首页 > 知识库问答 >
问题:

DataBuffer不写入文件

柯耀
2023-03-14
[...]

@Override
public Mono<Void> handle(WebSocketSession webSocketSession) {
    String filename = "Streamname_" + webSocketSession.getId();
    Path path = FileSystems.getDefault().getPath("C:\\Program Files (x86)\\Apache Software Foundation\\Tomcat 9.0\\webapps\\stream\\videos");
    //File filelocation = new File(path + filename);
    System.out.println("The path is: " + path);

    Flux<DataBuffer> videoDataFlux = webSocketSession.receive()
            .map(WebSocketMessage::getPayload);

    try {
        //AsynchronousFileChannel channel = AsynchronousFileChannel.open(path, StandardOpenOption.WRITE);
        //DataBufferUtils.write(videoDataFlux, channel, 0).subscribe();

        Path file = Files.createTempFile(path, filename, ".webm");
        WritableByteChannel channel = Files.newByteChannel(file, StandardOpenOption.WRITE);
        DataBufferUtils.write(videoDataFlux, channel)
                .map(DataBufferUtils::release)
                .then(Mono.just(file));
    } catch (IOException e) {
    }

    return webSocketSession.send(intervalFlux
            .map(webSocketSession::textMessage))
            .and(webSocketSession.receive());
    //.map(WebSocketMessage::getPayloadAsText).log());
}

我稍微改变了一下返回。Deleted.then(mono.just(file)),因为它可能导致websocket立即终止。我删除了.map(databufferutils::release,这也会导致终止套接字。或者更有可能是在套接字关闭后调用补丁。它仍然不能像我希望的那样工作,但至少它需要一堆blobs并将它们写入文件。不幸的是,它只在我停止客户端/代码后才写入文件。

@Override
public Mono<Void> handle(WebSocketSession webSocketSession) {
    try {
        String filename = "Streamname_" + webSocketSession.getId();
        Path path = FileSystems.getDefault().getPath("C:\\Program Files (x86)\\Apache Software Foundation\\Tomcat 9.0\\webapps\\stream\\videos");
        //File filelocation = new File(path + filename);
        System.out.println("The path is: " + path);

        Flux<DataBuffer> videoDataFlux = webSocketSession.receive()
                .map(WebSocketMessage::getPayload);

        //AsynchronousFileChannel channel = AsynchronousFileChannel.open(path, StandardOpenOption.WRITE);
        //DataBufferUtils.write(videoDataFlux, channel, 0).subscribe();
        Path file = Files.createTempFile(path, filename, ".webm");
        WritableByteChannel channel = Files.newByteChannel(file, StandardOpenOption.WRITE);

        return DataBufferUtils.write(videoDataFlux, channel)
                //.map(DataBufferUtils::release)
                .then(/*Mono.just(file)*/)
                .flatMap(out -> {
                    return webSocketSession.send(intervalFlux
                            .map(webSocketSession::textMessage))
                            .and(webSocketSession.receive());
                });
    } catch (IOException e) {
    }

    return webSocketSession.send(intervalFlux
            .map(webSocketSession::textMessage))
            .and(webSocketSession.receive());
    //.map(WebSocketMessage::getPayloadAsText).log());
}

这是更新2的更改之前

io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
        at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
        |_ checkpoint ? http://localhost:8081/ws/StreamInput/ [ReactorNettyRequestUpgradeStrategy]
Stack trace:
                at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:138) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:100) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.buffer.DefaultByteBufHolder.release(DefaultByteBufHolder.java:115) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at 
[...]

[...] 
                at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

2020-05-23 15:06:20.908  WARN 7888 --- [ctor-http-nio-4] io.netty.util.ReferenceCountUtil         : Failed to release a message: BinaryWebSocketFrame(data: PooledUnsafeDirectByteBuf(freed))

io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
        at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:138) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:100) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.buffer.DefaultByteBufHolder.release(DefaultByteBufHolder.java:115) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
        at 
[...]
[...]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

2020-05-23 15:06:20.970 ERROR 7888 --- [ctor-http-nio-4] r.n.channel.ChannelOperationsHandler     : [id: 0x156dc7a0, L:/[0:0:0:0:0:0:0:1]:8081 ! R:/[0:0:0:0:0:0:0:1]:53149] Error was received while reading the incoming data. The connection will be closed.

reactor.core.Exceptions$BubblingException: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
        at reactor.core.Exceptions.bubble(Exceptions.java:173) ~[reactor-core-3.3.4.RELEASE.jar:3.3.4.RELEASE]
        at reactor.core.publisher.Operators.onErrorDropped(Operators.java:590) ~[reactor-core-3.3.4.RELEASE.jar:3.3.4.RELEASE]
        at reactor.core.publisher.FluxFilter$FilterSubscriber.onError(FluxFilter.java:147) ~[reactor-core-3.3.4.RELEASE.jar:3.3.4.RELEASE]
        at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:418) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:243) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:353) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:352) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:493) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.http.server.WebsocketServerOperations.onInboundNext(WebsocketServerOperations.java:154) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:90) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) ~[netty-codec-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321) ~[netty-codec-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295) ~[netty-codec-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
        at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
        |_ checkpoint ? http://localhost:8081/ws/StreamInput/ [ReactorNettyRequestUpgradeStrategy]
Stack trace:
                at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:138) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:100) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.buffer.DefaultByteBufHolder.release(DefaultByteBufHolder.java:115) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:224) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
                at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:353) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
                at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:352) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
                at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:493) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
                at 
[...]
[...]   
                at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

2020-05-23 15:06:21.022 ERROR 7888 --- [ctor-http-nio-4] reactor.netty.tcp.TcpServer              : [id: 0x156dc7a0, L:/[0:0:0:0:0:0:0:1]:8081 ! R:/[0:0:0:0:0:0:0:1]:53149] onUncaughtException(SimpleConnection{channel=[id: 0x156dc7a0, L:/[0:0:0:0:0:0:0:1]:8081 ! R:/[0:0:0:0:0:0:0:1]:53149]})

reactor.core.Exceptions$BubblingException: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
        at reactor.core.Exceptions.bubble(Exceptions.java:173) ~[reactor-core-3.3.4.RELEASE.jar:3.3.4.RELEASE]
        at reactor.core.publisher.Operators.onErrorDropped(Operators.java:590) ~[reactor-core-3.3.4.RELEASE.jar:3.3.4.RELEASE]
        at reactor.core.publisher.FluxFilter$FilterSubscriber.onError(FluxFilter.java:147) ~[reactor-core-3.3.4.RELEASE.jar:3.3.4.RELEASE]
        at reactor.netty.channel.FluxReceive.terminateReceiver(FluxReceive.java:418) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:243) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:353) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:352) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:493) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
        at 
[...]
[...]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
        at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
        |_ checkpoint ? http://localhost:8081/ws/StreamInput/ [ReactorNettyRequestUpgradeStrategy]
Stack trace:
                at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:138) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:100) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.buffer.DefaultByteBufHolder.release(DefaultByteBufHolder.java:115) ~[netty-buffer-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:224) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
                at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:353) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
                at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:352) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
                at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:493) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]
                at reactor.netty.http.server.WebsocketServerOperations.onInboundNext(WebsocketServerOperations.java:154) ~[reactor-netty-0.9.6.RELEASE.jar:0.9.6.RELEASE]       
                at
[...]
[...]
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]    
                at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]    
                at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.48.Final.jar:4.1.48.Final]
                at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

共有1个答案

周苑博
2023-03-14

因为在这里:

DataBufferUtils.write(videoDataFlux, channel)
                            .map(DataBufferUtils::release)
                            .then(Mono.just(file));

你在弄断锁链。您忽略了这里的返回值。

您需要链接,而不是忽略返回,这段代码可能不起作用,但您得到了重点

return DataBufferUtils.write(videoDataFlux, channel)
                            .map(DataBufferUtils::release)
                            .then(Mono.just(file))
                            .flatMap(file -> {
                                return webSocketSession.send(intervalFlux
                                           .map(webSocketSession::textMessage))
                                           .and(webSocketSession.receive());
                            });
 类似资料:
  • 问题内容: 我必须从用户那里获取用户的名称和地址,并将其放入文本文件中。我写以下代码: 当我运行代码时,它需要用户输入,但文本文件为空。地址和名称未写入文本文件。如何在上面的代码中将名称和地址存储到文本文件中。 问题答案: 您创建的,但从来没有或它。 这些操作是实际写入文件的操作 正如@ManoDestra在注释中指出的那样,Java支持statement,它允许您将语句的格式设置为: 由于实现了

  • 我使用带有yaml配置的Log4j2。将日志记录到控制台工作得很好,每次都会创建一个外部日志文件,但它没有条目。谢谢你的提示。 src/Main/java/my/example/log/: 创建但为空的文件是

  • 问题内容: 因此,我正在使用 BufferedWriter, 并希望将一些文本写入文本文件。 由于某种原因,正在创建文本文档,但是没有写入任何文本,这是为什么呢? 问题答案: 您需要关闭或使用

  • 如果我试图写入脚本的目录或任何其他目录,则错误是相同的。权限似乎是对的。所有东西都是755,根所有者。我尝试将“my_custom_dir”所有者更改为www-data(apache用户),但没有任何区别。 它“死”在第一线。日志上的错误是“在/usr/lib/cgi-bin/script.cgi拒绝权限”

  • 我使用ubuntu 16.04。我想在有cassandra java api的程序中编写登录文件。日志可以写在java控制台中,但不能写在文件中。 我的节目: 还有我的log4j。属性:

  • 我的grails配置log4j部分中有以下内容: 文件“onetract3.log”已成功创建,但未向该文件写入任何内容。 我可以在控制台中看到信息处理正确。 Grails版本是2.3.5 知道为什么这没有写入日志文件吗? 编辑:10.03.1014,设置相加为false。