首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >连接mqtt时直接缓冲区内存错误

连接mqtt时直接缓冲区内存错误
EN

Stack Overflow用户
提问于 2022-03-16 07:06:14
回答 1查看 318关注 0票数 0

我们正在一个Flink集群上运行一个Apache应用程序。

由于应用程序在几天内失败,出现了以下错误:

代码语言:javascript
运行
复制
    Caused by: javax.net.ssl.SSLException: failure when writing TLS control frames
        at io.netty.handler.ssl.SslHandler.setHandshakeFailureTransportFailure(SslHandler.java:1870)
        at io.netty.handler.ssl.SslHandler.access$600(SslHandler.java:167)
        at io.netty.handler.ssl.SslHandler$2.operationComplete(SslHandler.java:985)
        at io.netty.handler.ssl.SslHandler$2.operationComplete(SslHandler.java:980)
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:577)
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:551)
        at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:490)
        at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:183)
        at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:95)
        at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:30)
        at io.netty.handler.ssl.SslHandler.wrapNonAppData(SslHandler.java:980)
        at io.netty.handler.ssl.SslHandler.handshake(SslHandler.java:2046)
        at io.netty.handler.ssl.SslHandler.startHandshakeProcessing(SslHandler.java:1966)
        at io.netty.handler.ssl.SslHandler.channelActive(SslHandler.java:2101)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:230)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:216)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelActive(AbstractChannelHandlerContext.java:209)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelActive(DefaultChannelPipeline.java:1398)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:230)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:216)
        at io.netty.channel.DefaultChannelPipeline.fireChannelActive(DefaultChannelPipeline.java:895)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:305)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:335)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.OutOfMemoryError: Direct buffer memory. The direct out-of-memory error has occurred. This can mean two things: either job(s) require(s) a larger size of JVM direct memory or there is a direct memory leak. The direct memory can be allocated by user code or some of its dependencies. In this case 'taskmanager.memory.task.off-heap.size' configuration option should be increased. Flink framework and its dependencies also consume the direct memory, mostly for network communication. The most of network memory is managed by Flink and should not result in out-of-memory error. In certain special cases, in particular for jobs with high parallelism, the framework may require more direct memory which is not managed by Flink. In this case 'taskmanager.memory.framework.off-heap.size' configuration option should be increased. If the error persists then there is probably a direct memory leak in user code or some of its dependencies which has to be investigated and fixed. The task executor has to be shutdown...

该连接是通过以下方法构建的:

代码语言:javascript
运行
复制
private Mqtt5AsyncClient setupClient() {
    Mqtt5ClientBuilder mqttClientBuilder = Mqtt5Client.builder().identifier("beam-"+UUID.randomUUID().toString())
        .serverHost(properties.getServerHost()).serverPort(properties.getServerPort());
    if (properties.getUsername() != null && properties.getPassword() != null) {
      mqttClientBuilder = mqttClientBuilder.simpleAuth().username(properties.getUsername())
          .password(properties.getPassword().getBytes()).applySimpleAuth();
    } else if (properties.getUsername() != null || properties.getPassword() != null) {
      LoggerFactory.getLogger(getClass()).error("Both username and password must be provided!");
    }

    if (properties.isSslEnabled()) { // Add ssl config if ssl is enabled
      try {
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
        ks.load(new ByteArrayInputStream(truststore), properties.getTrustStorePassword().toCharArray());

        tmf.init(ks);

        if (properties.skipHostnameVerification()) { // Disable host name verification if required
          mqttClientBuilder = mqttClientBuilder.sslConfig().trustManagerFactory(tmf)
              .hostnameVerifier(new NoopHostnameVerifier()).applySslConfig();
        } else {
          mqttClientBuilder = mqttClientBuilder.sslConfig().trustManagerFactory(tmf).applySslConfig();
        }
      } catch (NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e) {
        LoggerFactory.getLogger(getClass()).error("Error while setting up ssl", e);
      }
    }

    Mqtt5BlockingClient newClient = mqttClientBuilder.buildBlocking();
    newClient.connect();
    
    mqttClientCount.inc();
    return newClient.toAsync();
  }

,但是当我从eclipse项目启动应用程序时,它会在我的机器上运行,一切都很好。因此,错误只发生在Flink集群中,这使得调试有点困难。

服务器上唯一改变的是对openjdk-11.0.14的更新。将我的pc上的java更新到相同的版本根本不会产生错误。

所以我想不出会导致错误的原因了。

所以我检查了下面的内容

  • 是SSL证书有效的->是的
  • 是用户名和密码正确的?>是的
  • 在mqtt端是否有任何日志记录?>没有

Java应用程序似乎在连接到mqtt代理之前就失败了。因为在mqtt代理上没有任何登录尝试。

我们使用的是spring 2.1.18和hivemq-mqtt-客户端:1.2.2。经纪人是个天才。

欢迎任何建议。

提前感谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-25 08:34:44

所以我修好了。

我不知道问题到底出在哪里。

当所有工作正常时,我加载了vm的备份。然后,我将openjdk-11更新为最新版本。在此之后,错误再次出现。

所以,OpenJDK-11-JDK11.0.14的更新确实是个问题。

在删除openjdk并进行干净的重新安装之后,所有工作都可以再次正常工作。

也许这能帮上忙。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71492944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档