XxlJobRemotingUtil : Read timed out 解决

·  阅读 2467
XxlJobRemotingUtil   : Read timed out 解决

Spring cloud 整合的 XxlJob

生产环境日志信息里面包含大量重复的Read timed out错误信息

2021-08-11 23:48:13.857 ERROR 6 --- [rRegistryThread] c.xxl.job.core.util.XxlJobRemotingUtil   : Read timed out
java.net.SocketTimeoutException: Read timed out
        at java.base/java.net.SocketInputStream.socketRead0(Native Method) ~[na:na]
        at java.base/java.net.SocketInputStream.socketRead(Unknown Source) ~[na:na]
        at java.base/java.net.SocketInputStream.read(Unknown Source) ~[na:na]
        at java.base/java.net.SocketInputStream.read(Unknown Source) ~[na:na]
        at java.base/java.io.BufferedInputStream.fill(Unknown Source) ~[na:na]
        at java.base/java.io.BufferedInputStream.read1(Unknown Source) ~[na:na]
        at java.base/java.io.BufferedInputStream.read(Unknown Source) ~[na:na]
        at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source) ~[na:na]
        at java.base/sun.net.www.http.HttpClient.parseHTTP(Unknown Source) ~[na:na]
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) ~[na:na]
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) ~[na:na]
        at java.base/java.net.HttpURLConnection.getResponseCode(Unknown Source) ~[na:na]
        at com.xxl.job.core.util.XxlJobRemotingUtil.postBody(XxlJobRemotingUtil.java:115) ~[xxl-job-core-2.2.0.jar!/:na]
        at com.xxl.job.core.biz.client.AdminBizClient.registry(AdminBizClient.java:42) ~[xxl-job-core-2.2.0.jar!/:na]
        at com.xxl.job.core.thread.ExecutorRegistryThread$1.run(ExecutorRegistryThread.java:48) ~[xxl-job-core-2.2.0.jar!/:na]
        at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
2021-08-11 23:48:13.858  INFO 6 --- [rRegistryThread] c.x.j.c.thread.ExecutorRegistryThread    : >>>>>>>>>>> xxl-job registry fail, registryParam:RegistryParam{registryGroup='EXECUTOR', registryKey='baqianyi', registryValue='http://xx.xxx.xxx.76:9999/'}, registryResult:ReturnT [code=500, msg=xxl-rpc remoting error(Read timed out), for url : http://cloud-xxl-job:8080/xxl-job-admin/api/registry, content=null]
复制代码

从错误信息中能看出来xxl-job[注册线程]连接超时错误

原因是xxl-job注册失败,没有叫做baqianyi的key

xxl-job registry fail, registryParam:RegistryParam{registryGroup='EXECUTOR', registryKey='baqianyi', registryValue='http://xx.xxx.xxx.76:9999/'}, registryResult:ReturnT [code=500, msg=xxl-rpc remoting error(Read timed out), for url : http://cloud-xxl-job:8080/xxl-job-admin/api/registry, content=null]
复制代码

经过排查,我发现我当前的项目并没有使用xxl-job的功能,但是引用了他的依赖和xxl-job.yaml,导致它会不断的请求注册。

xxl-job配置文件如下

xxl-job:
  port: 9999
  admin-addresses: http://cloud-xxl-job:8080/xxl-job-admin
  app-name: ${spring.application.name}
  log-path: /root/log/xxl-job/
复制代码

解决方案

一、移除pom依赖

<!--        <dependency>-->
<!--            <groupId>com.htlm.common</groupId>-->
<!--            <artifactId>htlm-common-xxl-job</artifactId>-->
<!--            <version>1.0-SNAPSHOT</version>-->
<!--        </dependency>-->
复制代码

二、移除nacos配置的引用

spring:
  profiles:
    active: dev
  application:
    name: baqianyi
  cloud:
    nacos:
      discovery:
        server-addr: ${NACOS_IP}:8848
      config:
        server-addr: ${NACOS_IP}:8848
        file-extension: yaml
        extension-configs:
          - data-id: common-${spring.profiles.active}.yaml
            refresh: true
          - data-id: redis-${spring.profiles.active}.yaml
            refresh: true
          - data-id: stream-${spring.profiles.active}.yaml
            refresh: true
#       移除nacos关联的配置                
#          - data-id: xxl-job-${spring.profiles.active}.yaml
#            refresh: true
复制代码

总结

具体的错误出现的原因是因为,新的服务在搭建的时候,常常会在其他服务中复制粘贴配置文件过来,然而复制过来的配置文件就草草的改一下application应用名就了事了,从而引发一些bug。

分类:
代码人生
标签:
收藏成功!
已添加到「」, 点击更改