🐛 修复发送消息报错.

This commit is contained in:
lijiahang
2024-05-20 11:24:04 +08:00
parent 630291df46
commit 4eeedb85de
8 changed files with 175 additions and 12 deletions

View File

@@ -46,7 +46,10 @@ public class ExecLogTailHandler extends AbstractWebSocketHandler {
String trackerId = this.getTrackerId(id, info, host);
String absolutePath = logsFileClient.getAbsolutePath(host.getPath());
// 追踪器
ExecLogTracker tracker = new ExecLogTracker(trackerId, absolutePath, session, host);
ExecLogTracker tracker = new ExecLogTracker(trackerId,
absolutePath,
WebSockets.createSyncSession(session),
host);
// 执行
AssetThreadPools.EXEC_LOG.execute(tracker);
// 添加追踪器

View File

@@ -5,6 +5,7 @@ import com.orion.ext.tail.delay.DelayTrackerListener;
import com.orion.ext.tail.mode.FileNotFoundMode;
import com.orion.ext.tail.mode.FileOffsetMode;
import com.orion.spring.SpringHolder;
import com.orion.visor.framework.common.constant.Const;
import com.orion.visor.framework.websocket.core.utils.WebSockets;
import com.orion.visor.module.asset.define.config.AppTrackerConfig;
import com.orion.visor.module.asset.entity.dto.ExecHostLogTailDTO;
@@ -79,7 +80,20 @@ public class ExecLogTracker implements IExecLogTracker {
@Override
public void read(byte[] bytes, int len, Tracker tracker) {
WebSockets.sendText(session, config.getId() + LogConst.SEPARATOR + new String(bytes, 0, len));
// 发送消息
String message = config.getId() + LogConst.SEPARATOR + new String(bytes, 0, len);
try {
WebSockets.sendText(session, message);
return;
} catch (Exception e) {
log.error("ExecLogTracker.send error", e);
}
// 重试
try {
WebSockets.retrySendText(session, message, Const.MS_100);
} catch (Exception e) {
log.error("ExecLogTracker.resend error fk", e);
}
}
@Override