Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java &引用;“对等端重置连接”;在基于骆驼的应用程序中,当生产者关闭连接时_Java_Apache Camel_Netty - Fatal编程技术网

Java &引用;“对等端重置连接”;在基于骆驼的应用程序中,当生产者关闭连接时

Java &引用;“对等端重置连接”;在基于骆驼的应用程序中,当生产者关闭连接时,java,apache-camel,netty,Java,Apache Camel,Netty,我们使用camel框架和Netty客户端应用程序向生产者发送请求,其标题连接为:保持活动状态。 我们得到了正常响应(代码:200),一切看起来都正常。但几分钟后,制作者关闭了连接(使用tcp RST)。这导致了一个例外: java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.read0(Native Method) at sun.nio.ch.SocketDispatcher.

我们使用camel框架和Netty客户端
应用程序向生产者发送请求,其标题连接为:保持活动状态。
我们得到了正常响应(代码:200),一切看起来都正常。但几分钟后,制作者关闭了连接(使用tcp RST)。这导致了一个例外:

java.io.IOException: Connection reset by peer
    at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
    at sun.nio.ch.IOUtil.read(IOUtil.java:192)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
    at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1108)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:347)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
    at java.lang.Thread.run(Thread.java:748)
在日志文件中,我们还可以看到以下警告:
无法确定来自id为XXX-1573787037638-0-2421168的Exchange的当前路由,将回退并使用第一个错误处理程序。

我们发现此警告已登录到
org.apache.camel.processor.RedeliveryErrorHandler
,因为
uow==null
,但代码还包含注释:

// note this should really not happen, but we have this code as a fail safe 
// to be backwards compatible with the old behavior
由于此异常被应用程序异常处理程序捕获,这会导致很多混乱,为了暂时解决此问题,我们对SimpleChannelInboundHandler.exceptionCaught进行了重写

// signal callback
  if(exchange.getUnitOfWork() == null){
    LOG.warn("Exception without UnitOfWork, this is not propagated to Camel", cause);
} else {
    callback.done(false);
}
我们的解决方案是只有在有可用的UnitOfWork时才进行回调。但我们不确定这是正确的方法,或者这个解决方案是否会导致其他问题
有什么解决问题的建议吗

UPD。溃败:

 from(DIRECT_PRODUCER_ROUTE)
            .routeId(TO_PRODUCER_ROUTE)

            .onException(SocketException.class)
                .redeliveryDelay("{{producer.retry.delay}}")
                .maximumRedeliveries("{{producer.retry.attempts}}")
                    .logRetryAttempted(true)
                    .retryAttemptedLogLevel(LoggingLevel.WARN)
                    .logRetryStackTrace(false)
                .to(DIRECT_PRODUCER_ERROR)
                .handled(true)
            .end()
            .onException(ReadTimeoutException.class, NettyHttpOperationFailedException.class)
                .to(DIRECT_PRODUCER_ERROR)
                .handled(true)
            .end()

            .process(convertRequestCharset)
            .removeHeaders(headerFilter.getRequestHeadersToRemove(), headerFilter.getRequestHeadersToKeep())
            .bean(MessageInfoLogger.class, LOG_REQ_OUT_METHOD)
            .choice().when(exchangeProperty(ExchangeProperties.URL).contains("https://"))
                    .recipientList(simple(NETTY4_HTTPS_OUTGOING_TOD))
                    .endChoice()
                .otherwise()
                    .recipientList(simple(NETTY4_HTTP_TOD))
                    .endChoice()
            .end()
            .bean(MessageInfoLogger.class, LOG_RESP_IN_METHOD)
            .process(convertResponseCharset)
            .end();

        from(DIRECT_PRODUCER_ERROR)
            .process(handleProducerExceptionProcessor)
            .choice()
            .when(header(Exchange.HTTP_RESPONSE_CODE).isNotEqualTo("200"))
                .bean(MessageInfoLogger.class, LOG_ERROR_METHOD)
            .end()
            .process(convertResponseCharset)
            .removeHeaders(headerFilter.getResponseHeadersToRemove(), headerFilter.getResponseHeadersToKeep())
            .bean(MessageInfoLogger.class, LOG_RESP_OUT_METHOD)
            .end();

您能告诉我们您使用的是什么版本的ApacheCamel,并为您的路线发布代码吗?您使用的是什么版本的Camel?是的,也许我们可以对您正在做的事情做一些开箱即用的事情,忽略异常,因为它闻起来好像交易所已经超时并且已经完成了,但是需要更多的投资。2.24.0问题用rout更新。我创建了一个小项目来显示错误