客户端注册不到服务端问题如何排查?

Viewed 151

1、先检查配置的服务端 host、port、namespace、group、token是否都正确;

2、检查client、server的通信协议是否一致;

3、如果使用grpc协议通信,且server的grpc端口是nginx代理出来的,检查nginx配置是否按照grpc协议代理;

4、如果使用grpc协议通信,检查server和client的 protobuf 版本是否一致;

5、通过maven依赖检查工具,检查是否有其他依赖使用了protobuf-java,推荐使用IDEA自带的Analyze Dependencies,如果出现非snail-job引入的protobuf-java,即使版本号一样,也建议手工排除该依赖。

6、在lib分离打包方式中,如果某些依赖中包含protobuf-java,即使版本一样也可能会导致无法注册到服务端,且手工排除该依赖也无效,需要将protobuf-java相关的依赖和主程序打包到一起,参考以下方法:

新建一个maven模块,引入定时任务模块;

通过exclude打包时排除定时任务模块;

<profile>
  <id>zip</id>
  <build>
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <configuration>
              <mainClass>com.example.snailjob.SnailJobSpringbootApplication</mainClass>
              <layout>ZIP</layout>
              <excludes>
                <exclude>
                  <groupId>com.opensnail</groupId>
                  <artifactId>snailjob-demo</artifactId>
                </exclude>
              </excludes>
          </configuration>
          <executions>
              <execution>
                <goals>
                  <goal>repackage</goal>
                </goals>
              </execution>
          </executions>
        </plugin>
      </plugins>
  </build>
</profile>

打包后手动将定时任务模块打包的jar包放到lib目录下.

2 Answers

我最后发现是默认dev空间,切换到prod就看到机器上线了