[已解决] JRMP 连接出错 (Error during JRMP connection establishment)
wwxiaoqi opened this issue · comments
环境:
IntelliJ IDEA 2023.2 (Build #IU-232.8660.185, built on July 26, 2023)
HotSecondsClient 端版本:1.8.5
HotSecondsServer 端版本:HotSecondsServer-future2
Java version "1.8.0_382"
libjvm.so 使用版本:1.8.0_181
Debian GNU/Linux 12 x86_64
运行相关
该项目是在宝塔部署的 Spring Boot。
运行命令:
java -XXaltjvm=dcevm -javaagent:HotSecondsServer.jar=hotconf=hot-seconds-remote.xml -jar -Xmx1024M -Xms256M server.jar --server.port=9090 --spring.profiles.active=local
配置情况
hot-seconds-remote.xml
<?xml version="1.0" encoding="UTF-8"?>
<liubs>
<secret>Lvh7TXiv2AhyI3kNS4Ps19wI408NwR8fm4oxbk</secret>
<remote_port>45389</remote_port>
<timeout>5000</timeout>
<classloader>org.springframework.boot.loader.LaunchedURLClassLoader</classloader>
<dev-ext>
<classname>com.code.server.LaunchedClassLoader</classname>
</dev-ext>
</liubs>
hot-seconds.xml
<?xml version="1.0" encoding="UTF-8"?>
<liubs>
<secret>Lvh7TXiv2AhyI3kNS4Ps19wI408NwR8fm4oxbk</secret>
<remote_ip>127.0.0.1</remote_ip>
<remote_port>45389</remote_port>
<timeout>5000</timeout>
<auto_hotdeploy>false</auto_hotdeploy>
<mappings>
</mappings>
</liubs>
错误提示
在 HotSecondsClient 进行连接的时候出现:
[17:48:38] 初始化hot-seconds.xml:HotDeployConfig{ author='liubsyy', secret='Lvh7TXiv2AhyI3kNS4Ps19wI408NwR8fm4oxbk', remoteIp='127.0.0.1', remotePort=45389, timeout=5000, autoHotDeploy=false, mappings=[]}
[17:48:38] 初始化IHotDeployService失败:java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
java.net.SocketException: Connection reset
at java.rmi/sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:308)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:204)
at java.rmi/sun.rmi.server.UnicastRef.newCall(UnicastRef.java:344)
at java.rmi/sun.rmi.registry.RegistryImpl_Stub.lookup(RegistryImpl_Stub.java:116)
at com.liubs.ff.hotdeploy.HotDeployClient.lambda$initHotDeployConnectAsync$2(HotDeployClient.java:93)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.net.SocketException: Connection reset
at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:323)
at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:350)
at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:803)
at java.base/java.net.Socket$SocketInputStream.read(Socket.java:966)
at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:244)
at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:263)
at java.base/java.io.DataInputStream.readByte(DataInputStream.java:271)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:247)
... 6 more
运行日志
发现以下内容:
HOTSECONDS: 05:46:09.556 INFO HotDeployService热部署服务启动成功
HOTSECONDS: 05:47:46.147 INFO Executing XmlBeanDefinitionScannerAgent.reloadXml('file:hot-seconds-remote.xml')
HOTSECONDS: 05:47:46.148 ERROR failed to convert filePath hot-seconds-remote.xml to classPath path
HOTSECONDS: 05:47:46.148 WARNING url file:hot-seconds-remote.xml is not associated with any XmlBeanDefinitionScannerAgent, not reloading
/zulu8.72.0.17-ca-jdk8.0.382-linux_x64/bin/java: symbol lookup error: /zulu8.72.0.17-ca-jdk8.0.382-linux_x64/jre/lib/amd64/libjava.so: undefined symbol: JVM_BeforeHalt, version SUNWprivate_1.1
HOTSECONDS: 05:47:59.218 INFO Add tools.jar to classpath...
HOTSECONDS: 05:47:59.339 INFO findAllDependencyClasses[]
HOTSECONDS: 05:47:59.340 INFO findAllDependencyClasses[*.jar]
HOTSECONDS: 05:47:59.346 INFO Loading Hotswap agent {1.4.1} - unlimited runtime class redefinition.
HOTSECONDS: 05:48:00.109 INFO Discovered plugins: [MyBatis, Hotswapper, JdkPlugin, AnonymousClassPatch, ClassInitPlugin, WatchResources, Hibernate, Hibernate3JPA, Hibernate3, Spring, Jersey1, Jersey2, Jetty, Tomcat, ZK, Logback, Log4j2, MyFaces, Mojarra, Omnifaces, ELResolver, WildFlyELResolver, OsgiEquinox, Owb, Proxy, WebObjects, Weld, JBossModules, ResteasyRegistry, Deltaspike, GlassFish, Vaadin, Wicket, CxfJAXRS, FreeMarker, Undertow]
05:48:00.351 [main] INFO org.springframework.boot.devtools.restart.RestartApplicationListener - Restart disabled due to an agent-based reloader being active
HOTSECONDS: 05:48:01.109 INFO Plugin 'org.hotswap.agent.plugin.logback.LogbackPlugin' initialized in ClassLoader 'sun.misc.Launcher$AppClassLoader@18b4aac2'.
HOTSECONDS: 05:48:01.110 WARNING Unable to watch for path jar:file:/server-api.jar!/logback-config.xml, not a local regular file or directory.
HOTSECONDS: 05:48:01.110 INFO Logback plugin initialized.
HOTSECONDS: 05:48:01.231 INFO Plugin 'org.hotswap.agent.plugin.spring.SpringPlugin' initialized in ClassLoader 'sun.misc.Launcher$AppClassLoader@18b4aac2'.
HOTSECONDS: 05:48:01.231 INFO Spring plugin initialized - Spring core version '5.2.7.RELEASE'
HOTSECONDS: 05:48:01.573 INFO Registering basePackage com.wk.code.wkserver
HOTSECONDS: 05:48:01.698 INFO Registering basePackage springfox.documentation.swagger2.mappers
HOTSECONDS: 05:48:01.713 INFO Registering basePackage springfox.documentation.spring.web.scanners
HOTSECONDS: 05:48:01.718 INFO Registering basePackage springfox.documentation.spring.web.readers.operation
HOTSECONDS: 05:48:01.722 INFO Registering basePackage springfox.documentation.spring.web.readers.parameter
HOTSECONDS: 05:48:01.727 INFO Registering basePackage springfox.documentation.spring.web.plugins
HOTSECONDS: 05:48:01.729 INFO Registering basePackage springfox.documentation.spring.web.paths
HOTSECONDS: 05:48:01.755 INFO Registering basePackage springfox.documentation.schema
HOTSECONDS: 05:48:01.774 INFO Registering basePackage springfox.documentation.swagger.schema
HOTSECONDS: 05:48:01.778 INFO Registering basePackage springfox.documentation.swagger.readers
HOTSECONDS: 05:48:01.785 INFO Registering basePackage springfox.documentation.swagger.web
HOTSECONDS: 05:48:01.796 INFO Registering basePackage com.github.xiaoymin.knife4j.spring.plugin
HOTSECONDS: 05:48:01.797 INFO Registering basePackage com.github.xiaoymin.knife4j.spring.web
HOTSECONDS: 05:48:02.846 INFO Spring plugin initialized - Spring core version '5.2.7.RELEASE'
HOTSECONDS: 05:48:02.858 INFO Registering basePackage com.wk.code.wkserver.mapper
HOTSECONDS: 05:48:04.099 INFO Plugin 'org.hotswap.agent.plugin.tomcat.TomcatPlugin' initialized in ClassLoader 'TomcatEmbeddedWebappClassLoader
context: v1
delegate: true
----------> Parent Classloader:
sun.misc.Launcher$AppClassLoader@18b4aac2
'.
HOTSECONDS: 05:48:04.099 INFO Tomcat plugin initialized - Tomcat version '9.0.36.0'
HOTSECONDS: 05:48:05.009 INFO MyBatis plugin initialized.
HOTSECONDS: 05:48:05.009 INFO Plugin 'org.hotswap.agent.plugin.mybatis.MyBatisPlugin' initialized in ClassLoader 'sun.misc.Launcher$AppClassLoader@18b4aac2'.
自我尝试
- 根据 HotSecondsIDEA/wiki 中的常见问题和解决方案,尝试过在执行命令中加上
-Djava.rmi.server.hostname=远程ip
未解决 - 使用 SSH 将 HotSeconds 配置的端口转发到本地 127.0.0.1 尝试连接,未解决
- 待续..
目前怀疑 classloader 配置有问题,以及 libjava.so 待排查
三方面的问题都排查一下,1.远程端口是通的且本地用其他工具能连接上这个端口 2.jdk版本可能和libjvm不一致,你去掉-XXaltjvm=dcevm其他参数都保留启动服务器,看看客户端能连上吗 3.classloader填写不需要包名
问题已解决
连接
连接过程中发现日志需要打印如下内容才可以正常连接
HOTSECONDS: XX:XX:XX:XXX INFO HotDeployService热部署服务启动成功
这个过程需要大概等待 5 分钟左右,目前不清楚是不是定时器的问题。
Classloader 配置
项目设置了 ConfigurableApplicationContext
实际上需要设置 Classloader 为 AppClassLoader(可能不是这个原因,没有研究下去了)
配置这个选项可以使用如下命令放到 Spring Boot Application Main:
System.out.println(ServerApplication.class.getClassLoader());
配合启动日志中的 Parent Classloader 来配置:
HOTSECONDS: 05:48:04.099 INFO Plugin 'org.hotswap.agent.plugin.tomcat.TomcatPlugin' initialized in ClassLoader 'TomcatEmbeddedWebappClassLoader
context: v1
delegate: true
----------> Parent Classloader:
sun.misc.Launcher$AppClassLoader@18b4aac2
'.
正常运行命令
/usr/local/zulu8.72.0.17-ca-jdk8.0.382-linux_x64/bin/java
-Djava.rmi.server.hostname=XXX.XX.XXX.XX
-javaagent:HotSecondsServer.jar=hotconf=hot-seconds-remote.xml
-Xmx1024M -Xms256M
-jar server.jar
--server.port=9090
另外日志中有个字符串打错了:
HOTSECONDS: 11:40:57.737 INFO 超过5此移除:com.code.server.TestHotExtHandler
5此 -> 5次
5分钟延迟启动可以看看hot-seconds-remote.xml中的init_delay