mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-30 10:58:14 +08:00
fix node error
This commit is contained in:
parent
f8866275f0
commit
e930699cb7
@ -22,17 +22,29 @@
|
||||
*/
|
||||
package io.jpom.common.forward;
|
||||
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import io.jpom.common.JsonMessage;
|
||||
import io.jpom.system.AgentException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import top.jpom.transform.TransformServer;
|
||||
import top.jpom.transport.INodeInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.NoRouteToHostException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* json 消息转换
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 2022/12/24
|
||||
*/
|
||||
@Slf4j
|
||||
public class JsonMessageTransformServer implements TransformServer {
|
||||
|
||||
@Override
|
||||
@ -48,7 +60,30 @@ public class JsonMessageTransformServer implements TransformServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Exception transformException(Exception e, INodeInfo nodeInfo) {
|
||||
return NodeForward.responseException(e, nodeInfo);
|
||||
public Exception transformException(Exception exception, INodeInfo nodeModel) {
|
||||
if (exception instanceof NullPointerException) {
|
||||
log.error("{}节点,程序空指针异常", nodeModel.name(), exception);
|
||||
return new AgentException(nodeModel.name() + "节点异常,空指针");
|
||||
}
|
||||
String message = exception.getMessage();
|
||||
log.error("node [{}] connect failed...message: [{}]", nodeModel.name(), message);
|
||||
List<Throwable> throwableList = ExceptionUtil.getThrowableList(exception);
|
||||
for (Throwable throwable : throwableList) {
|
||||
if (throwable instanceof ConnectException || throwable instanceof SocketTimeoutException) {
|
||||
return new AgentException(nodeModel.name() + "节点网络连接异常或超时,请优先检查插件端运行状态再检查 IP 地址、" +
|
||||
"端口号是否配置正确,防火墙规则," +
|
||||
"云服务器的安全组配置等网络相关问题排查定位。" + message);
|
||||
}
|
||||
if (throwable instanceof UnknownHostException) {
|
||||
return new AgentException(nodeModel.name() + "无法访问节点网络(未知的名称或服务),请检查主机名或者 DNS 是否可用。" + message);
|
||||
}
|
||||
if (throwable instanceof NoRouteToHostException) {
|
||||
return new AgentException(nodeModel.name() + "节点通讯失败,远程地址和端口时发生错误的信号。通常,由于中间的防火墙或中间路由器已关闭,无法访问远程主机。" + message);
|
||||
}
|
||||
if (throwable instanceof IOException && StrUtil.containsIgnoreCase(message, "Error writing to server")) {
|
||||
return new AgentException(nodeModel.name() + "节点通讯失败,请优先检查限制上传大小配置是否合理,或者网络连接是否被代理终端、防火墙终端等。" + message);
|
||||
}
|
||||
}
|
||||
return new AgentException(nodeModel.name() + "节点异常:" + message);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ package io.jpom.common.forward;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.resource.BytesResource;
|
||||
import cn.hutool.core.io.unit.DataSize;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
@ -488,37 +487,6 @@ public class NodeForward {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件端 异常类型判断
|
||||
*
|
||||
* @param exception 异常
|
||||
* @param nodeModel 插件端
|
||||
*/
|
||||
public static AgentException responseException(Exception exception, INodeInfo nodeModel) {
|
||||
if (exception instanceof NullPointerException) {
|
||||
log.error("{}节点,程序空指针异常", nodeModel.name(), exception);
|
||||
return new AgentException(nodeModel.name() + "节点异常,空指针");
|
||||
}
|
||||
String message = exception.getMessage();
|
||||
Throwable cause = exception.getCause();
|
||||
log.error("node [{}] connect failed...message: [{}]", nodeModel.name(), message);
|
||||
if (exception instanceof IORuntimeException) {
|
||||
if (cause instanceof java.net.ConnectException || cause instanceof java.net.SocketTimeoutException) {
|
||||
return new AgentException(nodeModel.name() + "节点网络连接异常或超时,请优先检查插件端运行状态再检查 IP 地址、" +
|
||||
"端口号是否配置正确,防火墙规则," +
|
||||
"云服务器的安全组配置等网络相关问题排查定位。" + message);
|
||||
}
|
||||
} else if (exception instanceof cn.hutool.http.HttpException) {
|
||||
if (cause instanceof java.net.SocketTimeoutException) {
|
||||
return new AgentException(nodeModel.name() + "节点网络连接超时,请优先检查插件端运行状态再检查节点超时时间配置是否合理,上传文件超时时间配置是否合理。" + message);
|
||||
}
|
||||
if (cause instanceof IOException && StrUtil.containsIgnoreCase(message, "Error writing to server")) {
|
||||
return new AgentException(nodeModel.name() + "节点上传失败,请优先检查限制上传大小配置是否合理。" + message);
|
||||
}
|
||||
}
|
||||
return new AgentException(nodeModel.name() + "节点异常:" + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通消息转发,并解析数据
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user